Class: CanTango::PermissionEngine::Factory
- Inherits:
-
Object
- Object
- CanTango::PermissionEngine::Factory
- Includes:
- Helpers::Debug
- Defined in:
- lib/cantango/permission_engine/factory.rb
Instance Attribute Summary collapse
-
#ability ⇒ Object
Returns the value of attribute ability.
Instance Method Summary collapse
- #build! ⇒ Object
- #collector(type) ⇒ Object
- #config_path ⇒ Object
-
#initialize(ability) ⇒ Factory
constructor
creates the factory for the ability note that the ability contains the roles and role groups of the user (or account).
- #options ⇒ Object
- #permission_types ⇒ Object
- #store ⇒ Object
- #store_class ⇒ Object
- #store_options ⇒ Object
Methods included from Helpers::Debug
Constructor Details
#initialize(ability) ⇒ Factory
creates the factory for the ability note that the ability contains the roles and role groups of the user (or account)
11 12 13 |
# File 'lib/cantango/permission_engine/factory.rb', line 11 def initialize ability @ability = ability end |
Instance Attribute Details
#ability ⇒ Object
Returns the value of attribute ability.
6 7 8 |
# File 'lib/cantango/permission_engine/factory.rb', line 6 def ability @ability end |
Instance Method Details
#build! ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/cantango/permission_engine/factory.rb', line 15 def build! debug "building permissions" @evaluators ||= .inject([]) do |res, type| res << collector(type).build res end.flatten.compact end |
#collector(type) ⇒ Object
23 24 25 26 |
# File 'lib/cantango/permission_engine/factory.rb', line 23 def collector(type) rules = store.send(:"#{type}_rules") CanTango::PermissionEngine::Collector.new(ability, rules, type) end |
#config_path ⇒ Object
48 49 50 |
# File 'lib/cantango/permission_engine/factory.rb', line 48 def config_path .config_path end |
#options ⇒ Object
28 29 30 |
# File 'lib/cantango/permission_engine/factory.rb', line 28 def ability. end |
#permission_types ⇒ Object
44 45 46 |
# File 'lib/cantango/permission_engine/factory.rb', line 44 def .types end |
#store ⇒ Object
32 33 34 |
# File 'lib/cantango/permission_engine/factory.rb', line 32 def store store_class.new :permissions, end |
#store_class ⇒ Object
36 37 38 |
# File 'lib/cantango/permission_engine/factory.rb', line 36 def store_class .store.default_class end |
#store_options ⇒ Object
40 41 42 |
# File 'lib/cantango/permission_engine/factory.rb', line 40 def .store..merge(:path => config_path) end |