Class: EndecaOnDemand::Query
- Inherits:
-
Object
- Object
- EndecaOnDemand::Query
- Includes:
- PP
- Defined in:
- lib/endeca_on_demand/query.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
associations ##.
-
#client ⇒ Object
readonly
fields ##.
-
#errors ⇒ Object
readonly
fields ##.
-
#http ⇒ Object
readonly
fields ##.
-
#options ⇒ Object
readonly
fields ##.
-
#response ⇒ Object
readonly
fields ##.
-
#uri ⇒ Object
readonly
fields ##.
-
#xml ⇒ Object
readonly
fields ##.
Instance Method Summary collapse
- #advanced_parameters ⇒ Object
- #category ⇒ Object
- #dimensions ⇒ Object
-
#flags ⇒ Object
data ###.
-
#initialize(client, options = {}) ⇒ Query
constructor
A new instance of Query.
- #inspect_attributes ⇒ Object
- #paging ⇒ Object
- #searches ⇒ Object
- #sorts ⇒ Object
-
#to_xml ⇒ Object
xml builder ##.
Methods included from PP
Constructor Details
#initialize(client, options = {}) ⇒ Query
Returns a new instance of Query.
12 13 14 15 16 |
# File 'lib/endeca_on_demand/query.rb', line 12 def initialize(client, = {}) @client, @options = client, .dup.recurse(&:symbolize_keys) end |
Instance Attribute Details
#body ⇒ Object (readonly)
associations ##
10 11 12 |
# File 'lib/endeca_on_demand/query.rb', line 10 def body @body end |
#client ⇒ Object (readonly)
fields ##
10 11 12 |
# File 'lib/endeca_on_demand/query.rb', line 10 def client @client end |
#errors ⇒ Object (readonly)
fields ##
10 11 12 |
# File 'lib/endeca_on_demand/query.rb', line 10 def errors @errors end |
#http ⇒ Object (readonly)
fields ##
10 11 12 |
# File 'lib/endeca_on_demand/query.rb', line 10 def http @http end |
#options ⇒ Object (readonly)
fields ##
10 11 12 |
# File 'lib/endeca_on_demand/query.rb', line 10 def @options end |
#response ⇒ Object (readonly)
fields ##
10 11 12 |
# File 'lib/endeca_on_demand/query.rb', line 10 def response @response end |
#uri ⇒ Object (readonly)
fields ##
10 11 12 |
# File 'lib/endeca_on_demand/query.rb', line 10 def uri @uri end |
#xml ⇒ Object (readonly)
fields ##
10 11 12 |
# File 'lib/endeca_on_demand/query.rb', line 10 def xml @xml end |
Instance Method Details
#advanced_parameters ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/endeca_on_demand/query.rb', line 92 def advanced_parameters @advanced_parameters ||= [:advanced] = ([:advanced] || {}).inject({}) do |hash,(key,value)| hash.tap do hash[key.to_s.underscore] = value end end.symbolize_keys end |
#category ⇒ Object
76 77 78 |
# File 'lib/endeca_on_demand/query.rb', line 76 def category @category ||= [:category] end |
#dimensions ⇒ Object
72 73 74 |
# File 'lib/endeca_on_demand/query.rb', line 72 def dimensions @dimensions ||= [*[:dimensions]] end |
#flags ⇒ Object
data ###
60 61 62 63 64 65 66 |
# File 'lib/endeca_on_demand/query.rb', line 60 def flags @flags ||= [:flags] = ([:flags] || {}).inject({}) do |hash,(key,value)| hash.tap do hash[key.to_s.underscore] = value end end.symbolize_keys end |
#inspect_attributes ⇒ Object
6 |
# File 'lib/endeca_on_demand/query.rb', line 6 def inspect_attributes; [ :uri, :xml, :errors, :options ]; end |
#paging ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/endeca_on_demand/query.rb', line 84 def paging @paging ||= [:paging] = ([:paging] || {}).tap do |paging| if paging.has_key?(:page) and paging.has_key?(:per_page) paging[:offset] = (paging[:page].to_i * paging[:per_page].to_i rescue 0) end end end |
#searches ⇒ Object
68 69 70 |
# File 'lib/endeca_on_demand/query.rb', line 68 def searches @searches ||= [:searches] end |
#sorts ⇒ Object
80 81 82 |
# File 'lib/endeca_on_demand/query.rb', line 80 def sorts @sorts ||= [:sorts] end |
#to_xml ⇒ Object
xml builder ##
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/endeca_on_demand/query.rb', line 44 def to_xml Builder::XmlMarkup.new(indent: 2).tag!(:Query) do |xml| Flags(xml) KeywordSearch(xml) NavigationQuery(xml) CategoryNavigationQuery(xml) Sorting(xml) Paging(xml) AdvancedParameters(xml) end end |