Class: Flatter::Mapper::Factory
- Inherits:
-
Object
- Object
- Flatter::Mapper::Factory
- Includes:
- Mounting::FactoryMethods, Options::FactoryMethods, Target::FactoryMethods, Traits::FactoryMethods
- Defined in:
- lib/flatter/mapper/factory.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes included from Traits::FactoryMethods
Instance Method Summary collapse
- #create(mapper) ⇒ Object
- #fetch_target_from(mapper) ⇒ Object
-
#initialize(name, **options) ⇒ Factory
constructor
A new instance of Factory.
- #mapper_class ⇒ Object
- #mapper_class_name ⇒ Object
Methods included from Traits::FactoryMethods
Constructor Details
#initialize(name, **options) ⇒ Factory
Returns a new instance of Factory.
10 11 12 |
# File 'lib/flatter/mapper/factory.rb', line 10 def initialize(name, **) @name, @options = name.to_s, end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/flatter/mapper/factory.rb', line 8 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/flatter/mapper/factory.rb', line 8 def @options end |
Instance Method Details
#create(mapper) ⇒ Object
22 23 24 |
# File 'lib/flatter/mapper/factory.rb', line 22 def create(mapper) mapper_class.new(fetch_target_from(mapper)) end |
#fetch_target_from(mapper) ⇒ Object
26 27 28 |
# File 'lib/flatter/mapper/factory.rb', line 26 def fetch_target_from(mapper) default_target_from(mapper) end |
#mapper_class ⇒ Object
14 15 16 |
# File 'lib/flatter/mapper/factory.rb', line 14 def mapper_class [:mapper_class] || mapper_class_name.constantize end |
#mapper_class_name ⇒ Object
18 19 20 |
# File 'lib/flatter/mapper/factory.rb', line 18 def mapper_class_name [:mapper_class_name] || "#{name.to_s.camelize}Mapper" end |