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
55 56 57 58 59 60 61 |
# File 'lib/opensearch/dsl/search/base_compound_filter_component.rb', line 55 def call if @block && !@_block_called @block.arity < 1 ? instance_eval(&@block) : @block.call(self) end @_block_called = true self end |
#to_hash(options = {}) ⇒ Hash
Convert the component to a Hash
A default implementation, DSL classes can overload it.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/opensearch/dsl/search/base_compound_filter_component.rb', line 69 def to_hash( = {}) if @value.empty? && !@block @hash = super elsif @block call @hash = { name.to_sym => @value.map(&:to_hash) } else @hash = { name.to_sym => @value } end @hash end |