Class: Elastic::Core::SourceFormatter
- Inherits:
-
Object
- Object
- Elastic::Core::SourceFormatter
- Defined in:
- lib/elastic/core/source_formatter.rb
Instance Method Summary collapse
- #format(_source) ⇒ Object
- #format_field(_field, _value) ⇒ Object
-
#initialize(_definition) ⇒ SourceFormatter
constructor
A new instance of SourceFormatter.
Constructor Details
#initialize(_definition) ⇒ SourceFormatter
Returns a new instance of SourceFormatter.
3 4 5 |
# File 'lib/elastic/core/source_formatter.rb', line 3 def initialize(_definition) @definition = _definition end |
Instance Method Details
#format(_source) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/elastic/core/source_formatter.rb', line 13 def format(_source) _source.each do |key, value| field = @definition.get_field key next if field.nil? _source[key] = field.prepare_value_for_result(value) end end |
#format_field(_field, _value) ⇒ Object
7 8 9 10 11 |
# File 'lib/elastic/core/source_formatter.rb', line 7 def format_field(_field, _value) field = @definition.get_field _field return _value if field.nil? field.prepare_value_for_result _value end |