Module: EffectiveBootstrap

Defined in:
lib/effective_bootstrap.rb,
lib/effective_bootstrap/engine.rb,
lib/effective_bootstrap/version.rb,
lib/generators/effective_bootstrap/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Engine

Constant Summary collapse

VERSION =
'0.3.12'.freeze

Class Method Summary collapse

Class Method Details

.authorize!(controller, action, resource) ⇒ Object



27
28
29
# File 'lib/effective_bootstrap.rb', line 27

def self.authorize!(controller, action, resource)
  raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
end

.authorized?(controller, action, resource) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/effective_bootstrap.rb', line 14

def self.authorized?(controller, action, resource)
  @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact

  return !!authorization_method unless authorization_method.respond_to?(:call)
  controller = controller.controller if controller.respond_to?(:controller)

  begin
    !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
  rescue *@_exceptions
    false
  end
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



10
11
12
# File 'lib/effective_bootstrap.rb', line 10

def self.setup
  yield self
end