module OpenSearch::DSL::Search::BaseComponent::ClassMethods

Public Instance Methods

name(value=nil) click to toggle source

Get or set the name for the DSL class

@example Set the index name for the ‘Article` model and re-evaluate it on each call

class MyQuery
  include BaseComponent
  name :my_special_query
end

MyQuery.name
# => :my_special_query
# File lib/opensearch/dsl/search/base_component.rb, line 112
def name(value=nil)
  if value
    @name = value.to_sym
  else
    @name ||= begin
      value = self.to_s.split('::').last
      value.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
      value.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
      value.tr!("-", "_")
      value.downcase!
      value.to_sym
    end
  end
end
name=(value) click to toggle source

Set the name for the DSL class

# File lib/opensearch/dsl/search/base_component.rb, line 129
def name=(value)
  @name = value.to_sym
end
option_methods() click to toggle source
# File lib/opensearch/dsl/search/base_component.rb, line 133
def option_methods
  @option_methods ||= []
end