Class: Sunspot::Query::DynamicQuery

Inherits:
FieldQuery show all
Defined in:
lib/sunspot/query/dynamic_query.rb

Overview

A dynamic query is a proxy object that implements the API of the FieldQuery class, but wraps a dynamic field factory and thus applies the query components using dynamic field instances. – Dynamic queries do not hold their own state, but rather proxy to the query that generated them, adding components directly to the owning query’s internal state. ++ DynamicQuery instances are publicly generated by the Query#dynamic_query factory method.

Instance Method Summary collapse

Methods inherited from FieldQuery

#add_field_facet, #add_query_facet, #order_by

Methods inherited from Scope

#add_conjunction, #add_disjunction, #add_negated_restriction, #add_negated_shorthand_restriction, #add_restriction, #add_shorthand_restriction, #to_params

Constructor Details

#initialize(dynamic_field_factory, query) ⇒ DynamicQuery

:nodoc:



16
17
18
19
# File 'lib/sunspot/query/dynamic_query.rb', line 16

def initialize(dynamic_field_factory, query) #:nodoc:
  super(dynamic_field_factory)
  @query = query
end

Instance Method Details

#add_component(component) ⇒ Object

Add a component to the query



47
48
49
# File 'lib/sunspot/query/dynamic_query.rb', line 47

def add_component(component) #:nodoc:
  @query.add_component(component)
end

#add_sort(sort) ⇒ Object

Add a Sort to the query



40
41
42
# File 'lib/sunspot/query/dynamic_query.rb', line 40

def add_sort(sort) #:nodoc:
  @query.add_sort(sort)
end

#dynamic_query(field_name) ⇒ Object

This has the same effect as calling Query#exclude_instance; it is included for interface completeness.



33
34
35
# File 'lib/sunspot/query/dynamic_query.rb', line 33

def dynamic_query(field_name)
  @query.dynamic_query(field_name)
end

#exclude_instance(instance) ⇒ Object

This has the same effect as calling Query#exclude_instance; it is included for interface completeness.



25
26
27
# File 'lib/sunspot/query/dynamic_query.rb', line 25

def exclude_instance(instance)
  @query.exclude_instance(instance)
end