Module: Authority
- Defined in:
- lib/authority.rb,
lib/authority/railtie.rb,
lib/authority/version.rb,
lib/authority/abilities.rb,
lib/authority/controller.rb,
lib/authority/authorizer.rb,
lib/authority/configuration.rb,
lib/authority/user_abilities.rb,
lib/authority/security_violation.rb,
lib/generators/authority/install_generator.rb
Defined Under Namespace
Modules: Abilities, Controller, Generators, UserAbilities Classes: Authorizer, Configuration, NoAuthorizerError, Railtie, SecurityViolation
Constant Summary
- VERSION =
"2.5.0"
Class Attribute Summary (collapse)
-
+ (Object) configuration
Returns the value of attribute configuration.
Class Method Summary (collapse)
-
+ (Hash) abilities
NOTE: once this method is called, the library has started meta programming and abilities should no longer be modified.
- + (Boolean) action_authorized?(action, resource, user, options = {})
-
+ (Array) adjectives
Values from adjectives method.
- + (Object) configure {|configuration| ... }
-
+ (Model) enforce(action, resource, user, options = {})
Resource instance.
- + (Object) logger
-
+ (Array) verbs
Keys from adjectives method.
Class Attribute Details
+ (Object) configuration
Returns the value of attribute configuration
48 49 50 |
# File 'lib/authority.rb', line 48 def configuration @configuration end |
Class Method Details
+ (Hash) abilities
NOTE: once this method is called, the library has started meta programming and abilities should no longer be modified
15 16 17 |
# File 'lib/authority.rb', line 15 def self.abilities configuration.abilities.freeze end |
+ (Boolean) action_authorized?(action, resource, user, options = {})
42 43 44 45 |
# File 'lib/authority.rb', line 42 def self.(action, resource, user, = {}) = [resource, ].tap {|args| args.pop if args.last == {}} user.send("can_#{action}?", *) end |
+ (Array) adjectives
Values from adjectives method
25 26 27 |
# File 'lib/authority.rb', line 25 def self.adjectives abilities.values end |
+ (Object) configure {|configuration| ... }
51 52 53 54 55 56 57 |
# File 'lib/authority.rb', line 51 def self.configure self.configuration ||= Configuration.new yield(configuration) if block_given? configuration end |
+ (Model) enforce(action, resource, user, options = {})
Resource instance
35 36 37 38 39 40 |
# File 'lib/authority.rb', line 35 def self.enforce(action, resource, user, = {}) unless (action, resource, user, ) raise SecurityViolation.new(user, action, resource) end resource end |
+ (Object) logger
59 60 61 |
# File 'lib/authority.rb', line 59 def self.logger @logger ||= configuration.logger end |
+ (Array) verbs
Keys from adjectives method
20 21 22 |
# File 'lib/authority.rb', line 20 def self.verbs abilities.keys end |