Module: Elasticsearch::DSL::Search::BaseCompoundFilterComponent::InstanceMethods
- Defined in:
- lib/elasticsearch/dsl/search/base_compound_filter_component.rb
Overview
Common functionality for the compound filter components
Instance Method Summary collapse
-
#call ⇒ self
private
Evaluates the block passed to initializer, ensuring it is called just once.
-
#to_hash(options = {}) ⇒ Hash
Convert the component to a Hash.
Instance Method Details
#call ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Evaluates the block passed to initializer, ensuring it is called just once
47 48 49 50 51 |
# File 'lib/elasticsearch/dsl/search/base_compound_filter_component.rb', line 47 def call @block.arity < 1 ? self.instance_eval(&@block) : @block.call(self) if @block && ! @_block_called @_block_called = true self end |
#to_hash(options = {}) ⇒ Hash
Convert the component to a Hash
A default implementation, DSL classes can overload it.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/elasticsearch/dsl/search/base_compound_filter_component.rb', line 59 def to_hash(={}) case when @value.empty? && ! @block @hash = super when @block call @hash = { name.to_sym => @value.map { |i| i.to_hash } } else @hash = { name.to_sym => @value } end @hash end |