Sha256: 2954b91a21d30bb5d40057f5466891094b5d6251088eec70a3bc65291506de32
Contents?: true
Size: 1004 Bytes
Versions: 2
Compression:
Stored size: 1004 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 method_missing(symbol, *args) # if symbol != :attributes && attributes # attributes # attributes[symbol.to_s] # else # super # 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
topographer-0.0.9 | spec/topographer/importer/strategy/mapped_model.rb |
topographer-0.0.8 | spec/topographer/importer/strategy/mapped_model.rb |