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.



33
34
35
# File 'lib/flatter/mapper/mounting.rb', line 33

def mounter
  @mounter
end

#nameObject

Returns the value of attribute name.



33
34
35
# File 'lib/flatter/mapper/mounting.rb', line 33

def name
  @name
end

Instance Method Details

#full_nameObject



35
36
37
# File 'lib/flatter/mapper/mounting.rb', line 35

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

#mapping_namesObject



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

def mapping_names
  super + local_mountings.map(&:mapping_names).flatten
end

#mappingsObject



39
40
41
42
43
44
45
46
47
# File 'lib/flatter/mapper/mounting.rb', line 39

def mappings
  super.tap do |mappings|
    inner_mountings.each do |mounting|
      mounting.local_mappings.each do |mapping|
        mappings.merge!(mapping.name => mapping, &merging_proc)
      end
    end
  end
end

#mounting_namesObject



88
89
90
# File 'lib/flatter/mapper/mounting.rb', line 88

def mounting_names
  local_mounting_names + local_mountings.map(&:mounting_names).flatten
end

#mountingsObject



82
83
84
85
86
# File 'lib/flatter/mapper/mounting.rb', line 82

def mountings
  @mountings ||= inner_mountings.inject({}) do |res, mapper|
    res.merge(mapper.full_name => mapper, &merging_proc)
  end
end

#readObject



53
54
55
# File 'lib/flatter/mapper/mounting.rb', line 53

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

#rootObject



63
64
65
# File 'lib/flatter/mapper/mounting.rb', line 63

def root
  mounter.nil? ? self : mounter.root
end

#write(params) ⇒ Object



57
58
59
60
61
# File 'lib/flatter/mapper/mounting.rb', line 57

def write(params)
  super
  local_mountings.each{ |mapper| mapper.write(params) }
  @_inner_mountings = nil
end