Class: Elastic::Fields::Value
- Inherits:
-
Object
- Object
- Elastic::Fields::Value
- Extended by:
- Forwardable
- Defined in:
- lib/elastic/fields/value.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #disable_mapping_inference ⇒ Object
- #freeze ⇒ Object
- #get_field(_name) ⇒ Object
-
#initialize(_name, _options) ⇒ Value
constructor
A new instance of Value.
- #merge!(_options) ⇒ Object
- #needs_inference? ⇒ Boolean
- #nested? ⇒ Boolean
- #prepare_value_for_index(_value) ⇒ Object
- #prepare_value_for_query(_value) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(_name, _options) ⇒ Value
Returns a new instance of Value.
14 15 16 17 18 |
# File 'lib/elastic/fields/value.rb', line 14 def initialize(_name, ) @name = _name.to_s @options = .symbolize_keys @mapping_inference = true end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/elastic/fields/value.rb', line 5 def name @name end |
Instance Method Details
#disable_mapping_inference ⇒ Object
42 43 44 |
# File 'lib/elastic/fields/value.rb', line 42 def disable_mapping_inference @mapping_inference = false end |
#freeze ⇒ Object
46 47 48 49 50 |
# File 'lib/elastic/fields/value.rb', line 46 def freeze @name.freeze @options.freeze load_transform_and_datatype end |
#get_field(_name) ⇒ Object
29 30 31 |
# File 'lib/elastic/fields/value.rb', line 29 def get_field(_name) nil end |
#merge!(_options) ⇒ Object
24 25 26 27 |
# File 'lib/elastic/fields/value.rb', line 24 def merge!() return if .nil? @options.merge! .symbolize_keys end |
#needs_inference? ⇒ Boolean
38 39 40 |
# File 'lib/elastic/fields/value.rb', line 38 def needs_inference? mapping_inference_enabled? && !@options.key?(:type) end |
#nested? ⇒ Boolean
20 21 22 |
# File 'lib/elastic/fields/value.rb', line 20 def nested? false end |
#prepare_value_for_index(_value) ⇒ Object
57 58 59 60 |
# File 'lib/elastic/fields/value.rb', line 57 def prepare_value_for_index(_value) _value = @transform.apply _value if @transform @datatype.prepare_for_index _value end |
#prepare_value_for_query(_value) ⇒ Object
52 53 54 55 |
# File 'lib/elastic/fields/value.rb', line 52 def prepare_value_for_query(_value) _value = @transform.apply _value if @transform @datatype.prepare_for_query _value end |
#validate ⇒ Object
33 34 35 36 |
# File 'lib/elastic/fields/value.rb', line 33 def validate return "explicit field type for #{@name} required" unless @options.key? :type nil end |