Module: Eson::Search::Facet

Included in:
FilterFacet, GeoDistance, Histogram, QueryFacet, Range, Statistical, Terms, TermsStats
Defined in:
lib/eson/search/facet.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, arg) ⇒ Object



38
39
40
41
# File 'lib/eson/search/facet.rb', line 38

def method_missing(name, arg)
  warn("#{name} called as a facet option")
  self.options[name] = arg
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



22
23
24
# File 'lib/eson/search/facet.rb', line 22

def args
  @args
end

#scope_nameObject

Returns the value of attribute scope_name.



22
23
24
# File 'lib/eson/search/facet.rb', line 22

def scope_name
  @scope_name
end

Class Method Details

.included(base) ⇒ Object



16
17
18
19
20
# File 'lib/eson/search/facet.rb', line 16

def self.included(base)
  base.class_eval do
    extend ClassMethods
  end
end

Instance Method Details

#param(name) ⇒ Object



24
25
26
# File 'lib/eson/search/facet.rb', line 24

def param(name)
  args[name] || (raise "Parameter #{name} not given")
end

#scope(query, name) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/eson/search/facet.rb', line 28

def scope(query, name)
  case query
  when Nested, HasChild
    query.options[:_scope] = name
    self.scope_name = name
  else
    raise "Cannot scope unless Query is a Nested or HasChild Query"
  end
end