Class: Elasticated::Mapping::Builder
- Inherits:
-
Object
- Object
- Elasticated::Mapping::Builder
- Includes:
- Elasticated::Mixins::BlockEvaluation
- Defined in:
- lib/elasticated/mapping/builder.rb
Instance Attribute Summary collapse
-
#mapping_types ⇒ Object
Returns the value of attribute mapping_types.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object (also: #to_h)
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #type(name, &block) ⇒ Object
Methods included from Elasticated::Mixins::BlockEvaluation
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
18 19 20 |
# File 'lib/elasticated/mapping/builder.rb', line 18 def initialize self.mapping_types = Array.new end |
Instance Attribute Details
#mapping_types ⇒ Object
Returns the value of attribute mapping_types.
15 16 17 |
# File 'lib/elasticated/mapping/builder.rb', line 15 def mapping_types @mapping_types end |
Class Method Details
.build(&block) ⇒ Object
6 7 8 9 10 |
# File 'lib/elasticated/mapping/builder.rb', line 6 def build(&block) instance = new instance.evaluate block instance end |
Instance Method Details
#build ⇒ Object Also known as: to_h
28 29 30 31 32 |
# File 'lib/elasticated/mapping/builder.rb', line 28 def build mapping_types.inject({}) do |hash, mapping_type| hash.merge mapping_type.build end end |
#type(name, &block) ⇒ Object
22 23 24 25 26 |
# File 'lib/elasticated/mapping/builder.rb', line 22 def type(name, &block) mapping_type = TypeBuilder.new name mapping_type.evaluate block mapping_types << mapping_type end |