Sha256: da7ed86e556e9b0ef1031dc497b4e0161ebcb1434cf91b92eda4fb7db2793202
Contents?: true
Size: 605 Bytes
Versions: 4
Compression:
Stored size: 605 Bytes
Contents
module SearchKit module Models class Document class AttributeNotFound < StandardError; end include Virtus.model attribute :id attribute :source attribute :score def initialize(document_data = {}) attributes = document_data.fetch(:attributes, {}) super( source: attributes, id: attributes.fetch(:id, nil), score: attributes.fetch(:score, nil) ) end def get(field) source.fetch(field.to_sym) rescue KeyError fail AttributeNotFound, field end end end end
Version data entries
4 entries across 4 versions & 1 rubygems