Class: Elasticated::Mapping::ObjectBuilder
- Inherits:
-
FieldsBuilder
- Object
- FieldsBuilder
- Elasticated::Mapping::ObjectBuilder
- Defined in:
- lib/elasticated/mapping/object_builder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#object_attributes ⇒ Object
Returns the value of attribute object_attributes.
Attributes inherited from FieldsBuilder
#hash, #name, #nesteds, #sub_objects
Instance Method Summary collapse
- #accept_new_fields ⇒ Object
- #add_attribute(name, value) ⇒ Object
- #base_body ⇒ Object
-
#build_body ⇒ Object
override.
-
#dynamic(value) ⇒ Object
‘dynamic’ attribute.
- #ignore_new_fields ⇒ Object
-
#initialize(*args) ⇒ ObjectBuilder
constructor
A new instance of ObjectBuilder.
- #strict ⇒ Object
Methods inherited from FieldsBuilder
#add_property, #analyzed_string, #bool, #build, #date, #double, #float, #integer, #long, #nested, #object, #partial, #string
Methods included from Elasticated::Mixins::BlockEvaluation
Constructor Details
#initialize(*args) ⇒ ObjectBuilder
Returns a new instance of ObjectBuilder.
7 8 9 10 |
# File 'lib/elasticated/mapping/object_builder.rb', line 7 def initialize(*args) super self.object_attributes = Hash.new end |
Instance Attribute Details
#object_attributes ⇒ Object
Returns the value of attribute object_attributes.
5 6 7 |
# File 'lib/elasticated/mapping/object_builder.rb', line 5 def object_attributes @object_attributes end |
Instance Method Details
#accept_new_fields ⇒ Object
43 44 45 |
# File 'lib/elasticated/mapping/object_builder.rb', line 43 def accept_new_fields dynamic Enum::Mapping::Dynamic::ACCEPT_NEW_FIELDS end |
#add_attribute(name, value) ⇒ Object
12 13 14 |
# File 'lib/elasticated/mapping/object_builder.rb', line 12 def add_attribute(name, value) object_attributes[name] = value end |
#base_body ⇒ Object
16 17 18 |
# File 'lib/elasticated/mapping/object_builder.rb', line 16 def base_body { type: :object } end |
#build_body ⇒ Object
override
21 22 23 24 25 26 27 |
# File 'lib/elasticated/mapping/object_builder.rb', line 21 def build_body ret = base_body properties = super ret.merge! properties: properties unless properties.empty? ret.merge! object_attributes unless object_attributes.empty? ret end |
#dynamic(value) ⇒ Object
‘dynamic’ attribute
31 32 33 |
# File 'lib/elasticated/mapping/object_builder.rb', line 31 def dynamic(value) add_attribute :dynamic, value end |
#ignore_new_fields ⇒ Object
39 40 41 |
# File 'lib/elasticated/mapping/object_builder.rb', line 39 def ignore_new_fields dynamic Enum::Mapping::Dynamic::IGNORE_NEW_FIELDS end |