Class: Elasticated::Mapping::FieldsBuilder
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
#add_property(name, value) ⇒ Object
16
17
18
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 16
def add_property(name, value)
hash[name] = value
end
|
#analyzed_string(field_name) ⇒ Object
44
45
46
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 44
def analyzed_string(field_name)
add_property field_name, build_analyzed_string_field(field_name)
end
|
#bool(field_name) ⇒ Object
48
49
50
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 48
def bool(field_name)
add_property field_name, build_bool_field
end
|
#build ⇒ Object
79
80
81
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 79
def build
{ name => build_body }
end
|
#build_body ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 68
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
20
21
22
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 20
def date(field_name)
add_property field_name, build_date_field
end
|
#double(field_name) ⇒ Object
32
33
34
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 32
def double(field_name)
add_property field_name, build_double_field
end
|
#float(field_name) ⇒ Object
28
29
30
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 28
def float(field_name)
add_property field_name, build_float_field
end
|
#integer(field_name) ⇒ Object
36
37
38
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 36
def integer(field_name)
add_property field_name, build_integer_field
end
|
#long(field_name) ⇒ Object
40
41
42
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 40
def long(field_name)
add_property field_name, build_long_field
end
|
#nested(nested_name, &block) ⇒ Object
58
59
60
61
62
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 58
def nested(nested_name, &block)
nested = NestedBuilder.new nested_name
nested.evaluate block
nesteds << nested
end
|
#object(object_name, &block) ⇒ Object
52
53
54
55
56
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 52
def object(object_name, &block)
sub_object = ObjectBuilder.new object_name
sub_object.evaluate block
sub_objects << sub_object
end
|
#partial(partial_mapping) ⇒ Object
64
65
66
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 64
def partial(partial_mapping)
partial_mapping.apply_over self
end
|
#string(field_name) ⇒ Object
24
25
26
|
# File 'lib/elasticated/mapping/fields_builder.rb', line 24
def string(field_name)
add_property field_name, build_string_field
end
|