Sha256: 56c6b27dce9da418bae579aea67114c292dd405db941d3df75259882552a7e17
Contents?: true
Size: 596 Bytes
Versions: 1
Compression:
Stored size: 596 Bytes
Contents
class Supernova::Solr::Mapper DEFAULT_MAPPINGS = { :id => :id } SUFFIXES = { :string => :s, :integer => :i, :float => :f, :boolean => :b, :multi_string => :ms, :time => :dt, :date => :dt, } def initialize(mapping = {}) @mapping = DEFAULT_MAPPINGS.merge(mapping).inject({}) do |hash, (from, to)| hash[from] = SUFFIXES[to] ? :"#{from}_#{SUFFIXES[to]}" : to hash end end def map(hash) mapping.inject({}) do |solr_hash, (from, to)| solr_hash[to] = hash[from] solr_hash end end private attr_reader :mapping end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
supernova-core-0.0.1 | lib/supernova/solr/mapper.rb |