class AbstractImporter::Mapping

Attributes

collection[R]
depends_on[R]
foreign_key[R]

Public Class Methods

new(collection, association) click to toggle source
# File lib/abstract_importer/mapping.rb, line 5
def initialize(collection, association)
  @collection = collection
  @depends_on = association.table_name.to_sym
  @foreign_key = association.foreign_key.to_sym
end

Public Instance Methods

applicable?(attrs) click to toggle source
# File lib/abstract_importer/mapping.rb, line 11
def applicable?(attrs)
  attrs.key?(foreign_key)
end
apply(attrs) click to toggle source
# File lib/abstract_importer/mapping.rb, line 19
def apply(attrs)
  collection.map_foreign_key(attrs[foreign_key], foreign_key, depends_on)
end
apply!(attrs) click to toggle source
# File lib/abstract_importer/mapping.rb, line 15
def apply!(attrs)
  attrs[foreign_key] = apply(attrs)
end
inspect() click to toggle source
# File lib/abstract_importer/mapping.rb, line 23
def inspect
  "#<#{self.class.name} #{self}>"
end
to_s() click to toggle source
# File lib/abstract_importer/mapping.rb, line 27
def to_s
  "#{collection.name}.#{foreign_key}"
end