Module: Flatter::Mapper::Mounting

Extended by:
ActiveSupport::Concern
Included in:
Flatter::Mapper
Defined in:
lib/flatter/mapper/mounting.rb

Defined Under Namespace

Modules: ClassMethods, FactoryMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mounterObject

Returns the value of attribute mounter.



28
29
30
# File 'lib/flatter/mapper/mounting.rb', line 28

def mounter
  @mounter
end

#nameObject

Returns the value of attribute name.



28
29
30
# File 'lib/flatter/mapper/mounting.rb', line 28

def name
  @name
end

Instance Method Details

#full_nameObject



30
31
32
# File 'lib/flatter/mapper/mounting.rb', line 30

def full_name
  [mounter.try(:name), name].compact.join('_')
end

#mappingsObject



34
35
36
37
38
39
40
41
42
# File 'lib/flatter/mapper/mounting.rb', line 34

def mappings
  super.tap do |mappings|
    inner_mountings.each do |mounting|
      mounting.local_mappings.each do |mapping|
        mappings[mapping.name] = mapping
      end
    end
  end
end

#mounting(name) ⇒ Object



75
76
77
# File 'lib/flatter/mapper/mounting.rb', line 75

def mounting(name)
  mountings[name.to_s]
end

#mountingsObject



69
70
71
72
73
# File 'lib/flatter/mapper/mounting.rb', line 69

def mountings
  @mountings ||= inner_mountings.each_with_object({}) do |mapper, res|
    res[mapper.full_name] = mapper
  end
end

#readObject



44
45
46
# File 'lib/flatter/mapper/mounting.rb', line 44

def read
  inner_mountings.map(&:read).inject(super, :merge)
end

#write(params) ⇒ Object



48
49
50
51
52
# File 'lib/flatter/mapper/mounting.rb', line 48

def write(params)
  super.tap do
    inner_mountings.each{ |mapper| mapper.write(params) }
  end
end