Class: CanTango::PermissionEngine::Permission
- Inherits:
-
Object
- Object
- CanTango::PermissionEngine::Permission
- Defined in:
- lib/cantango/permission_engine/permission.rb
Instance Attribute Summary collapse
-
#compiled_rules ⇒ Object
rules is a Hashie, a Hash where keys can also be accessed as method calls.
-
#name ⇒ Object
rules is a Hashie, a Hash where keys can also be accessed as method calls.
-
#static_rules ⇒ Object
rules is a Hashie, a Hash where keys can also be accessed as method calls.
Instance Method Summary collapse
- #compile_rules! ⇒ Object
- #compiler ⇒ Object
-
#initialize(name) ⇒ Permission
constructor
A new instance of Permission.
- #key ⇒ Object
- #to_compiled_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name) ⇒ Permission
Returns a new instance of Permission.
7 8 9 10 11 |
# File 'lib/cantango/permission_engine/permission.rb', line 7 def initialize name @name = name @static_rules = Hashie::Mash.new @compiled_rules = Hashie::Mash.new end |
Instance Attribute Details
#compiled_rules ⇒ Object
rules is a Hashie, a Hash where keys can also be accessed as method calls
5 6 7 |
# File 'lib/cantango/permission_engine/permission.rb', line 5 def compiled_rules @compiled_rules end |
#name ⇒ Object
rules is a Hashie, a Hash where keys can also be accessed as method calls
5 6 7 |
# File 'lib/cantango/permission_engine/permission.rb', line 5 def name @name end |
#static_rules ⇒ Object
rules is a Hashie, a Hash where keys can also be accessed as method calls
5 6 7 |
# File 'lib/cantango/permission_engine/permission.rb', line 5 def static_rules @static_rules end |
Instance Method Details
#compile_rules! ⇒ Object
30 31 32 33 |
# File 'lib/cantango/permission_engine/permission.rb', line 30 def compile_rules! compiler.compile! self @compiled_rules = compiler.to_hashie end |
#compiler ⇒ Object
35 36 37 |
# File 'lib/cantango/permission_engine/permission.rb', line 35 def compiler @compiler ||= CanTango::PermissionEngine::Compiler.new end |
#key ⇒ Object
13 14 15 |
# File 'lib/cantango/permission_engine/permission.rb', line 13 def key name.to_s end |
#to_compiled_hash ⇒ Object
21 22 23 |
# File 'lib/cantango/permission_engine/permission.rb', line 21 def to_compiled_hash {key => compiled_rules} end |
#to_hash ⇒ Object
17 18 19 |
# File 'lib/cantango/permission_engine/permission.rb', line 17 def to_hash {key => static_rules.to_hash} end |