Sha256: 8d5ab474886c8cca42d7b2a9beee34f9eb8b0a3ad9ea1414f940dee34c6b3bd7

Contents?: true

Size: 924 Bytes

Versions: 17

Compression:

Stored size: 924 Bytes

Contents

require 'inline_svg'
require 'effective_bootstrap/engine'
require 'effective_bootstrap/version'

module EffectiveBootstrap

  # The following are all valid config keys
  mattr_accessor :authorization_method

  def self.setup
    yield self
  end

  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

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

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
effective_bootstrap-0.0.17 lib/effective_bootstrap.rb
effective_bootstrap-0.0.16 lib/effective_bootstrap.rb
effective_bootstrap-0.0.15 lib/effective_bootstrap.rb
effective_bootstrap-0.0.14 lib/effective_bootstrap.rb
effective_bootstrap-0.0.13 lib/effective_bootstrap.rb
effective_bootstrap-0.0.12 lib/effective_bootstrap.rb
effective_bootstrap-0.0.11 lib/effective_bootstrap.rb
effective_bootstrap-0.0.10 lib/effective_bootstrap.rb
effective_bootstrap-0.0.9 lib/effective_bootstrap.rb
effective_bootstrap-0.0.8 lib/effective_bootstrap.rb
effective_bootstrap-0.0.7 lib/effective_bootstrap.rb
effective_bootstrap-0.0.6 lib/effective_bootstrap.rb
effective_bootstrap-0.0.5 lib/effective_bootstrap.rb
effective_bootstrap-0.0.4 lib/effective_bootstrap.rb
effective_bootstrap-0.0.3 lib/effective_bootstrap.rb
effective_bootstrap-0.0.2 lib/effective_bootstrap.rb
effective_bootstrap-0.0.1 lib/effective_bootstrap.rb