module Flatter::Mapper::Mounting

Attributes

mounter[RW]
name[RW]

Public Instance Methods

full_name() click to toggle source
# File lib/flatter/mapper/mounting.rb, line 35
def full_name
  [mounter.try(:name), name].compact.join('_')
end
mapping_names() click to toggle source
Calls superclass method
# File lib/flatter/mapper/mounting.rb, line 49
def mapping_names
  super + local_mountings.map(&:mapping_names).flatten
end
mappings() click to toggle source
Calls superclass method
# 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_names() click to toggle source
# File lib/flatter/mapper/mounting.rb, line 88
def mounting_names
  local_mounting_names + local_mountings.map(&:mounting_names).flatten
end
mountings() click to toggle source
# 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
read() click to toggle source
Calls superclass method
# File lib/flatter/mapper/mounting.rb, line 53
def read
  local_mountings.map(&:read).inject(super, :merge)
end
root() click to toggle source
# File lib/flatter/mapper/mounting.rb, line 63
def root
  mounter.nil? ? self : mounter.root
end
write(params) click to toggle source
Calls superclass method
# File lib/flatter/mapper/mounting.rb, line 57
def write(params)
  super
  local_mountings.each{ |mapper| mapper.write(params) }
  @_inner_mountings = nil
end

Protected Instance Methods

as_inner_mountings() click to toggle source
# File lib/flatter/mapper/mounting.rb, line 102
def as_inner_mountings
  [self, inner_mountings]
end
inner_mountings() click to toggle source
# File lib/flatter/mapper/mounting.rb, line 97
def inner_mountings
  @_inner_mountings ||= local_mountings.map{ |mount| mount.as_inner_mountings }.flatten
end
local_mountings() click to toggle source
# File lib/flatter/mapper/mounting.rb, line 67
def local_mountings
  class_mountings_for(self.class)
end

Private Instance Methods

class_mountings(klass) click to toggle source
# File lib/flatter/mapper/mounting.rb, line 77
def class_mountings(klass)
  klass.mountings.values
end
class_mountings_for(klass) click to toggle source
# File lib/flatter/mapper/mounting.rb, line 72
def class_mountings_for(klass)
  class_mountings(klass).map{ |factory| factory.create(self) }
end
local_mounting_names() click to toggle source
# File lib/flatter/mapper/mounting.rb, line 92
def local_mounting_names
  local_mountings.map(&:name)
end
merging_proc() click to toggle source
# File lib/flatter/mapper/mounting.rb, line 107
def merging_proc
  proc { |_, old, new| Array(old).push(new) }
end