Sha256: e565dd87a4d5d103fa2a009eb6022ca62714dd60f34dd844ffb7626d8a2846a1

Contents?: true

Size: 826 Bytes

Versions: 6

Compression:

Stored size: 826 Bytes

Contents

class MappedModel < OpenStruct
  def self.create(params)
    self.new(params)
  end

  def first
    self
  end

  def valid?
    self.errors = OpenStruct.new(full_messages: [])
    if field_2 == 'datum2'
      true
    else
      self.errors = OpenStruct.new(full_messages: ['Field 2 is not datum2'])
      false
    end
  end

  def save
    true
  end

  def self.get_mapper
    Topographer::Importer::Mapper.build_mapper(MappedModel) do |mapping|
      mapping.required_mapping 'Field1', 'field_1'
      mapping.required_mapping 'Field2', 'field_2'
      mapping.optional_mapping 'Field3', 'field_3'
      mapping.key_field 'field_1'
      mapping.key_field 'field_2'
    end
  end

  def self.where(params)
    return self.new(params)
  end

  def self.find_or_initialize_by(params)
    return self.new(params)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
topographer-0.0.7 spec/topographer/importer/strategy/mapped_model.rb
topographer-0.0.6 spec/topographer/importer/strategy/mapped_model.rb
topographer-0.0.5 spec/topographer/importer/strategy/mapped_model.rb
topographer-0.0.4 spec/topographer/importer/strategy/mapped_model.rb
topographer-0.0.3 spec/Topographer/importer/strategy/mapped_model.rb
topographer-0.0.2 spec/Cartographer/importer/strategy/mapped_model.rb