Class: Flex::Scope

Inherits:
Vars
  • Object
show all
Includes:
FilterMethods, QueryMethods, VarsMethods
Defined in:
lib/flex/scope.rb,
lib/flex/scope/utils.rb,
lib/flex/scope/vars_methods.rb,
lib/flex/scope/query_methods.rb,
lib/flex/scope/filter_methods.rb

Overview

never instantiate this class directly: it is automatically done by the scoped method

Defined Under Namespace

Modules: FilterMethods, Query, QueryMethods, Utils, VarsMethods Classes: Error

Constant Summary collapse

SCOPED_METHODS =
FilterMethods.instance_methods + VarsMethods.instance_methods + QueryMethods.instance_methods

Instance Method Summary collapse

Methods included from QueryMethods

#all, #count, #delete, #each, #find, #first, #last, #scan_all

Methods included from VarsMethods

#facets, #fields, #highlight, #index, #metrics, #page, #params, #query_string, #script_fields, #size, #sort, #type, #variables

Methods included from FilterMethods

#filters, #missing, #range, #term, #terms

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/flex/scope.rb', line 21

def method_missing(meth, *args, &block)
  super unless respond_to?(meth)
  case
  when is_context_scope?(meth)
    deep_merge self[:context].send(meth, *args, &block)
  when is_self_scope?(meth)
    deep_merge self[:self_context].send(meth, *args, &block)
  when is_template?(meth)
    self[:context].send(meth, deep_merge(*args), &block)
  end
end

Instance Method Details

#inspectObject



13
14
15
# File 'lib/flex/scope.rb', line 13

def inspect
  "#<#{self.class.name} #{self}>"
end

#respond_to?(meth, private = false) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/flex/scope.rb', line 17

def respond_to?(meth, private=false)
  super || is_template?(meth) || is_context_scope?(meth) || is_self_scope?(meth)
end