Sha256: 32789e7c2747ed059e71a2797e71e00e459ffa45d808ceab2c9e8dd973218ed5
Contents?: true
Size: 616 Bytes
Versions: 2
Compression:
Stored size: 616 Bytes
Contents
# Indexes the ActiveModel instance for search, based on # the mapping outlined using ElasticMapper::Mapping. module ElasticMapper::Index # Index the ActiveModel in ElasticSearch. def index mapping_name = self.class.instance_variable_get(:@_mapping_name) ElasticMapper.index.type(mapping_name).put(self.id, index_hash) end # Generate a hash representation of the model. # # @return [Hash] hash representation of model. def index_hash mapping = self.class.instance_variable_get(:@_mapping) mapping.inject({}) do |h, (k, v)| h[k] = self.send(v[:field]) h end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elastic_mapper-0.1.0 | lib/elastic_mapper/index.rb |
elastic_mapper-0.0.1 | lib/elastic_mapper/index.rb |