class Elastictastic::ScopeBuilder

Public Class Methods

build(&block) click to toggle source
# File lib/elastictastic/scope_builder.rb, line 6
def build(&block)
  new(&block).build
end
new(&block) click to toggle source
# File lib/elastictastic/scope_builder.rb, line 11
def initialize(&block)
  @block = block
end

Public Instance Methods

build() click to toggle source
# File lib/elastictastic/scope_builder.rb, line 15
def build
  @scope = {}
  instance_eval(&@block)
  @scope
end
method_missing(method, *args, &block) click to toggle source
# File lib/elastictastic/scope_builder.rb, line 21
def method_missing(method, *args, &block)
  args << ScopeBuilder.build(&block) if block
  value =
    case args.length
    when 0 then {}
    when 1 then args.first
    else args
    end
  @scope[method.to_s] = value
end