Class: CanTango::PermitEngine::Factory
- Inherits:
-
Object
- Object
- CanTango::PermitEngine::Factory
- Defined in:
- lib/cantango/permit_engine/factory.rb
Instance Attribute Summary collapse
-
#ability ⇒ Object
Returns the value of attribute ability.
-
#builders ⇒ Object
Returns the value of attribute builders.
Instance Method Summary collapse
- #build! ⇒ Object
- #builder_class(builder) ⇒ Object
- #create_builder(builder) ⇒ 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
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)
9 10 11 |
# File 'lib/cantango/permit_engine/factory.rb', line 9 def initialize ability @ability = ability end |
Instance Attribute Details
#ability ⇒ Object
Returns the value of attribute ability.
4 5 6 |
# File 'lib/cantango/permit_engine/factory.rb', line 4 def ability @ability end |
#builders ⇒ Object
Returns the value of attribute builders.
4 5 6 |
# File 'lib/cantango/permit_engine/factory.rb', line 4 def builders @builders end |
Instance Method Details
#build! ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cantango/permit_engine/factory.rb', line 13 def build! @builders ||= builders.inject([]) do |res, builder| res << create_builder(builder).build res end.flatten.compact end |
#builder_class(builder) ⇒ Object
25 26 27 28 |
# File 'lib/cantango/permit_engine/factory.rb', line 25 def builder_class builder return "CanTango::PermitEngine::Builder::SpecialPermits" if builder == :special "CanTango::Permits::#{builder.to_s.camelize}Permit::Builder" end |
#create_builder(builder) ⇒ Object
20 21 22 23 |
# File 'lib/cantango/permit_engine/factory.rb', line 20 def create_builder builder clazz = builder_class(builder) clazz.constantize.new(ability) end |
#options ⇒ Object
34 35 36 |
# File 'lib/cantango/permit_engine/factory.rb', line 34 def ability. end |