module Authority
Constants
- NoAuthorizerError
- VERSION
Attributes
configuration[RW]
Public Class Methods
abilities()
click to toggle source
NOTE: once this method is called, the library has started meta programming and abilities should no longer be modified @return [Hash] list of abilities, mapping verbs and adjectives, like :create => 'creatable'
# File lib/authority.rb, line 16 def self.abilities configuration.abilities.freeze end
adjectives()
click to toggle source
@return [Array] values from adjectives method
# File lib/authority.rb, line 26 def self.adjectives abilities.values end
configure() { |configuration| ... }
click to toggle source
# File lib/authority.rb, line 52 def self.configure self.configuration ||= Configuration.new yield(configuration) if block_given? require_authority_internals! configuration end
enforce(action, resource, user, options = {})
click to toggle source
@param [Symbol] action @param [Model] resource instance @param [User] user instance @param [Hash] options, arbitrary options hash to delegate to the authorizer @raise [SecurityViolation] if user is not allowed to perform action on resource @return [Model] resource instance
# File lib/authority.rb, line 36 def self.enforce(action, resource, user, options = {}) unless action_authorized?(action, resource, user, options) raise SecurityViolation.new(user, action, resource) end end
logger()
click to toggle source
# File lib/authority.rb, line 60 def self.logger configuration.logger end
verbs()
click to toggle source
@return [Array] keys from adjectives method
# File lib/authority.rb, line 21 def self.verbs abilities.keys end