Sha256: a50c71919360d469f719e70db23ecce69c50400e96c0a56af95706dd863d384f

Contents?: true

Size: 963 Bytes

Versions: 60

Compression:

Stored size: 963 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.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
  end

end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
effective_bootstrap-0.1.7 lib/effective_bootstrap.rb
effective_bootstrap-0.1.6 lib/effective_bootstrap.rb
effective_bootstrap-0.1.5 lib/effective_bootstrap.rb
effective_bootstrap-0.1.4 lib/effective_bootstrap.rb
effective_bootstrap-0.1.3 lib/effective_bootstrap.rb
effective_bootstrap-0.1.2 lib/effective_bootstrap.rb
effective_bootstrap-0.1.1 lib/effective_bootstrap.rb
effective_bootstrap-0.1.0 lib/effective_bootstrap.rb
effective_bootstrap-0.0.29 lib/effective_bootstrap.rb
effective_bootstrap-0.0.28 lib/effective_bootstrap.rb
effective_bootstrap-0.0.27 lib/effective_bootstrap.rb
effective_bootstrap-0.0.26 lib/effective_bootstrap.rb
effective_bootstrap-0.0.25 lib/effective_bootstrap.rb
effective_bootstrap-0.0.24 lib/effective_bootstrap.rb
effective_bootstrap-0.0.23 lib/effective_bootstrap.rb
effective_bootstrap-0.0.22 lib/effective_bootstrap.rb
effective_bootstrap-0.0.21 lib/effective_bootstrap.rb
effective_bootstrap-0.0.20 lib/effective_bootstrap.rb
effective_bootstrap-0.0.19 lib/effective_bootstrap.rb
effective_bootstrap-0.0.18 lib/effective_bootstrap.rb