Class: Flatter::Mapper::Factory
- Inherits:
-
Object
- Object
- Flatter::Mapper::Factory
- Includes:
- Collection::FactoryMethods, Mounting::FactoryMethods, Options::FactoryMethods, Target::FactoryMethods, Traits::FactoryMethods
- Defined in:
- lib/flatter/mapper/factory.rb
Constant Summary collapse
- NoTargetError =
Class.new(RuntimeError)
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 ⇒ Object
- #default_mapper_class_name ⇒ 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
Methods included from Collection::FactoryMethods
Constructor Details
#initialize(name, **options) ⇒ Factory
Returns a new instance of Factory.
13 14 15 |
# File 'lib/flatter/mapper/factory.rb', line 13 def initialize(name, **) @name, @options = name.to_s, end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/flatter/mapper/factory.rb', line 11 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/flatter/mapper/factory.rb', line 11 def @options end |
Instance Method Details
#create ⇒ Object
36 37 38 |
# File 'lib/flatter/mapper/factory.rb', line 36 def create(*) mapper_class.new.tap{ |mapper| mapper.factory = self } end |
#default_mapper_class_name ⇒ Object
32 33 34 |
# File 'lib/flatter/mapper/factory.rb', line 32 def default_mapper_class_name "#{name.camelize}Mapper" end |
#fetch_target_from(mapper) ⇒ Object
49 50 51 |
# File 'lib/flatter/mapper/factory.rb', line 49 def fetch_target_from(mapper) default_target_from(mapper) end |
#mapper_class ⇒ Object
17 18 19 |
# File 'lib/flatter/mapper/factory.rb', line 17 def mapper_class [:mapper_class] || default_mapper_class end |
#mapper_class_name ⇒ Object
28 29 30 |
# File 'lib/flatter/mapper/factory.rb', line 28 def mapper_class_name [:mapper_class_name] || modulize(default_mapper_class_name) end |