Class: MoulinRouge::Authorization
- Inherits:
-
Object
- Object
- MoulinRouge::Authorization
- Defined in:
- lib/moulin_rouge/authorization.rb
Overview
An sinlgeton inherited instace of this class acts like a proxy to main ability evaluating all methods in its scope to proper later evaluation
Class Method Summary collapse
-
.abilities ⇒ Object
Returns an hash with all permissions defined.
-
.compile! ⇒ Object
Load and initialize all authorization files in the configuration path.
-
.main ⇒ Object
The instance of the main ability.
-
.method_missing(name, *args, &block) ⇒ Object
Delegates the missing method for the main ability.
-
.register(instance) ⇒ Object
Register an ability in the singleton.
-
.reset! ⇒ Object
Reset all constants.
-
.roles ⇒ Object
Returns an array with the name of all roles created.
Class Method Details
.abilities ⇒ Object
Returns an hash with all permissions defined
26 27 28 |
# File 'lib/moulin_rouge/authorization.rb', line 26 def abilities @@abilities ||= {} end |
.compile! ⇒ Object
Load and initialize all authorization files in the configuration path
38 39 40 |
# File 'lib/moulin_rouge/authorization.rb', line 38 def compile! Dir[MoulinRouge.configuration.path].each { |file| Kernel.load(file) } end |
.main ⇒ Object
The instance of the main ability
16 17 18 |
# File 'lib/moulin_rouge/authorization.rb', line 16 def main @@main ||= MoulinRouge::Ability.new(:main) end |
.method_missing(name, *args, &block) ⇒ Object
Delegates the missing method for the main ability
11 12 13 |
# File 'lib/moulin_rouge/authorization.rb', line 11 def method_missing(name, *args, &block) main.send(name, *args, &block) end |
.register(instance) ⇒ Object
Register an ability in the singleton
31 32 33 34 35 |
# File 'lib/moulin_rouge/authorization.rb', line 31 def register(instance) name = instance.name self.abilities[name] = instance self.roles << name unless self.roles.include?(name) end |
.reset! ⇒ Object
Reset all constants
43 44 45 |
# File 'lib/moulin_rouge/authorization.rb', line 43 def reset! #:nodoc: @@main, @@roles, @@abilities = nil end |
.roles ⇒ Object
Returns an array with the name of all roles created
21 22 23 |
# File 'lib/moulin_rouge/authorization.rb', line 21 def roles @@roles ||= [] end |