Class: CheapSkate::Document
- Inherits:
-
Ferret::Document
- Object
- Ferret::Document
- CheapSkate::Document
- Defined in:
- lib/cheap_skate/models.rb
Instance Attribute Summary collapse
-
#doc_id ⇒ Object
Returns the value of attribute doc_id.
-
#index ⇒ Object
Returns the value of attribute index.
Instance Method Summary collapse
- #add_field(key, value) ⇒ Object
-
#initialize(doc_id = UUID.generate, boost = 1.0) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(doc_id = UUID.generate, boost = 1.0) ⇒ Document
Returns a new instance of Document.
4 5 6 7 |
# File 'lib/cheap_skate/models.rb', line 4 def initialize(doc_id=UUID.generate, boost=1.0) @doc_id = doc_id super(boost) end |
Instance Attribute Details
#doc_id ⇒ Object
Returns the value of attribute doc_id.
3 4 5 |
# File 'lib/cheap_skate/models.rb', line 3 def doc_id @doc_id end |
#index ⇒ Object
Returns the value of attribute index.
3 4 5 |
# File 'lib/cheap_skate/models.rb', line 3 def index @index end |
Instance Method Details
#add_field(key, value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cheap_skate/models.rb', line 10 def add_field(key, value) @index.set_dynamic_field(key.to_sym) unless @index.schema.field_names.index(key.to_sym) if value.is_a?(Array) value.each do |v| add_field(key, v) end else self[key.to_sym] ||= [] self[key.to_sym] << value end if copy_fields = @index.schema.copy_fields[key.to_sym] copy_fields.each do |field| add_field(field, value) end end end |