Module: ElasticRecord::FromSearchHit
- Defined in:
- lib/elastic_record/from_search_hit.rb
Instance Method Summary collapse
Instance Method Details
#from_search_hit(hit) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/elastic_record/from_search_hit.rb', line 4 def from_search_hit(hit) hit = hit['_source'].merge('id' => hit['_id']) attrs = value_from_search_hit_object(hit) if respond_to?(:instantiate) instantiate(attrs) else self.new.tap do |record| attrs.each do |k, v| record.send("#{k}=", v) if record.respond_to?("#{k}=") end end end end |