Class: Elasticated::Mapping::FieldsBuilder
- Inherits:
-
Object
- Object
- Elasticated::Mapping::FieldsBuilder
show all
- Includes:
- BlockEvaluation
- Defined in:
- lib/elasticated/mapping/fields_builder.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#evaluate
Constructor Details
Returns a new instance of FieldsBuilder.
9
10
11
12
13
14
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 9
def initialize(name)
self.hash = Hash.new
self.sub_objects = Array.new
self.nesteds = Array.new
self.name = name
end
|
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
7
8
9
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 7
def hash
@hash
end
|
#name ⇒ Object
Returns the value of attribute name.
7
8
9
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 7
def name
@name
end
|
#nesteds ⇒ Object
Returns the value of attribute nesteds.
7
8
9
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 7
def nesteds
@nesteds
end
|
#sub_objects ⇒ Object
Returns the value of attribute sub_objects.
7
8
9
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 7
def sub_objects
@sub_objects
end
|
Instance Method Details
#analyzed_string(field_name) ⇒ Object
40
41
42
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 40
def analyzed_string(field_name)
hash[field_name] = build_analyzed_string_field field_name
end
|
#bool(field_name) ⇒ Object
44
45
46
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 44
def bool(field_name)
hash[field_name] = build_bool_field
end
|
#build ⇒ Object
75
76
77
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 75
def build
{ name => build_body }
end
|
#build_body ⇒ Object
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 64
def build_body
ret = hash
sub_objects.each do |sub_object|
ret.merge! sub_object.build
end
nesteds.each do |nested|
ret.merge! nested.build
end
ret
end
|
#date(field_name) ⇒ Object
16
17
18
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 16
def date(field_name)
hash[field_name] = build_date_field
end
|
#double(field_name) ⇒ Object
28
29
30
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 28
def double(field_name)
hash[field_name] = build_double_field
end
|
#float(field_name) ⇒ Object
24
25
26
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 24
def float(field_name)
hash[field_name] = build_float_field
end
|
#integer(field_name) ⇒ Object
32
33
34
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 32
def integer(field_name)
hash[field_name] = build_integer_field
end
|
#long(field_name) ⇒ Object
36
37
38
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 36
def long(field_name)
hash[field_name] = build_long_field
end
|
#nested(nested_name, &block) ⇒ Object
54
55
56
57
58
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 54
def nested(nested_name, &block)
nested = NestedBuilder.new nested_name
nested.evaluate block
nesteds << nested
end
|
#object(object_name, &block) ⇒ Object
48
49
50
51
52
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 48
def object(object_name, &block)
sub_object = ObjectBuilder.new object_name
sub_object.evaluate block
sub_objects << sub_object
end
|
#partial(partial_mapping) ⇒ Object
60
61
62
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 60
def partial(partial_mapping)
partial_mapping.apply_over self
end
|
#string(field_name) ⇒ Object
20
21
22
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 20
def string(field_name)
hash[field_name] = build_string_field
end
|