Module: OpenSearch::DSL::Search::BaseCompoundFilterComponent::InstanceMethods
- Defined in:
- lib/opensearch/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
56 57 58 59 60 |
# File 'lib/opensearch/dsl/search/base_compound_filter_component.rb', line 56 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.
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/opensearch/dsl/search/base_compound_filter_component.rb', line 68 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 |