module Elasticsearch::DSL::Search::BaseCompoundFilterComponent::InstanceMethods

Common functionality for the compound filter components

Public Instance Methods

call() click to toggle source

Evaluates the block passed to initializer, ensuring it is called just once

@return [self]

@api private

# 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={}) click to toggle source

Convert the component to a Hash

A default implementation, DSL classes can overload it.

@return [Hash]

Calls superclass method
# File lib/elasticsearch/dsl/search/base_compound_filter_component.rb, line 59
def to_hash(options={})
  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