class Authority::Authorizer

Attributes

resource[R]

The base Authorizer class, from which all the authorizers in an app will descend. Provides the authorizer with both class and instance methods like `updatable_by?(user)`. Exactly which methods get defined is determined from `config.abilities`; the class is evaluated after any user-supplied config block is run in order to make that possible.

Public Class Methods

default(adjective, user, options = {}) click to toggle source

Whitelisting approach: anything not specified will be forbidden

# File lib/authority/authorizer.rb, line 17
def self.default(adjective, user, options = {})
  false
end
new(resource) click to toggle source
# File lib/authority/authorizer.rb, line 12
def initialize(resource)
  @resource = resource
end

Private Class Methods

user_and_maybe_options(user, options = {}) click to toggle source
# File lib/authority/authorizer.rb, line 41
def self.user_and_maybe_options(user, options = {})
  [user, options].tap {|args| args.pop if args.last == {}}
end

Public Instance Methods

default(adjective, user, options = {}) click to toggle source

the instance default method calls the class default method

# File lib/authority/authorizer.rb, line 22
def default(adjective, user, options = {})
  user_and_maybe_options = self.class.send(:user_and_maybe_options, user, options)
  self.class.send(:"#{adjective}_by?", *user_and_maybe_options)
end