Sha256: d44189751484aef9fe6f88ec76e77e2979d0c0d592c002b5a8cc932bdc3b8cb4

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

require 'simple_form'
require 'effective_resources'
require 'effective_datatables/engine'
require 'effective_datatables/version'

module EffectiveDatatables
  mattr_accessor :authorization_method

  mattr_accessor :default_length
  mattr_accessor :html_class
  mattr_accessor :save_state
  mattr_accessor :max_cookie_size

  mattr_accessor :actions_column # A Hash
  mattr_accessor :debug

  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

5 entries across 5 versions & 1 rubygems

Version Path
effective_datatables-3.6.3 lib/effective_datatables.rb
effective_datatables-3.6.1 lib/effective_datatables.rb
effective_datatables-3.6.0 lib/effective_datatables.rb
effective_datatables-3.5.4 lib/effective_datatables.rb
effective_datatables-3.5.3 lib/effective_datatables.rb