Class: Flatter::Mapper::Factory

Inherits:
Object
  • Object
show all
Includes:
Mounting::FactoryMethods, Options::FactoryMethods, Target::FactoryMethods, Traits::FactoryMethods
Defined in:
lib/flatter/mapper/factory.rb

Instance Attribute Summary collapse

Attributes included from Traits::FactoryMethods

#extension

Instance Method Summary collapse

Methods included from Traits::FactoryMethods

#trait?, #traits

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, **options)
  @name, @options = name.to_s, options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/flatter/mapper/factory.rb', line 8

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/flatter/mapper/factory.rb', line 8

def options
  @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_classObject



14
15
16
# File 'lib/flatter/mapper/factory.rb', line 14

def mapper_class
  options[:mapper_class] || mapper_class_name.constantize
end

#mapper_class_nameObject



18
19
20
# File 'lib/flatter/mapper/factory.rb', line 18

def mapper_class_name
  options[:mapper_class_name] || "#{name.to_s.camelize}Mapper"
end