Module: Strongbolt::BoltedController::InstanceMethods

Defined in:
lib/strongbolt/bolted_controller.rb

Instance Method Summary collapse

Instance Method Details

#can?(*args) ⇒ Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/strongbolt/bolted_controller.rb', line 138

def can?(*args)
  Strongbolt.current_user.can?(*args)
end

#cannot?(*args) ⇒ Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/strongbolt/bolted_controller.rb', line 142

def cannot?(*args)
  Strongbolt.current_user.cannot?(*args)
end

#render(*args) ⇒ Object

We’re aliasing render so we can trigger the without auth

DOESN’T WORK WHEN DEFINED HERE?



159
160
161
162
163
164
165
# File 'lib/strongbolt/bolted_controller.rb', line 159

def render(*args)
  if render_without_authorization?
    Strongbolt.without_authorization { _render(*args) }
  else
    _render(*args)
  end
end

#render_without_authorization?Boolean

Checks if the current action needs verification

Returns:

  • (Boolean)


149
150
151
152
# File 'lib/strongbolt/bolted_controller.rb', line 149

def render_without_authorization?
  self.class.actions_without_authorization.present? &&
    self.class.actions_without_authorization.include?(params[:action].to_sym)
end