Class: Skala::Adapter::Search::Request
- Inherits:
-
Operation::Request
- Object
- Operation::Request
- Skala::Adapter::Search::Request
- Defined in:
- lib/skala/adapter/search/request.rb
Defined Under Namespace
Classes: DateHistogramFacet, Facet, HistogramFacet, IdsQuery, MatchQuery, OrderedTermsQuery, Query, QueryStringQuery, RangeFacet, RangeQuery, SimpleQueryStringQuery, SortRequest, TermsFacet, UnscoredTermsQuery
Class Method Summary collapse
- .facet_factory(value) ⇒ Object
-
.factory(postfix) ⇒ Object
helpers to implement facets/queries setters.
- .query_factory(value) ⇒ Object
Instance Method Summary collapse
-
#facet_queries=(value) ⇒ Object
override (facet_)queries setters in order to determine query type.
-
#facets=(value) ⇒ Object
override facet setter in order to determine facet type.
- #queries=(value) ⇒ Object
-
#to_param ⇒ Object
TODO: move to frontend.
Methods included from DeepDupable
Class Method Details
.facet_factory(value) ⇒ Object
78 79 80 |
# File 'lib/skala/adapter/search/request.rb', line 78 def self.facet_factory(value) factory(:facet).call(value) end |
.factory(postfix) ⇒ Object
helpers to implement facets/queries setters
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/skala/adapter/search/request.rb', line 66 def self.factory(postfix) # e.g. :facet or :query which turns to "#{type}_#{postfix}", e.g. "match_query" or "range_facet" -> (value) do class_name = "#{value[:type] || value["type"]}_#{postfix}".classify if const_defined?(class_name) const_get(class_name).new(value) else raise ArgumentError.new("Unknown #{postfix} type!") end end end |
.query_factory(value) ⇒ Object
82 83 84 |
# File 'lib/skala/adapter/search/request.rb', line 82 def self.query_factory(value) factory(:query).call(value) end |
Instance Method Details
#facet_queries=(value) ⇒ Object
override (facet_)queries setters in order to determine query type
43 44 45 46 47 48 49 50 51 |
# File 'lib/skala/adapter/search/request.rb', line 43 def facet_queries=(value) if sanitized_value = [value].flatten(1).compact.presence mapped_values = sanitized_value.map do |_element| _element.is_a?(Hash) ? self.class.query_factory(_element) : _element end super(mapped_values) end end |
#facets=(value) ⇒ Object
override facet setter in order to determine facet type
32 33 34 35 36 37 38 39 40 |
# File 'lib/skala/adapter/search/request.rb', line 32 def facets=(value) if sanitized_value = [value].flatten(1).compact.presence mapped_values = sanitized_value.map do |_element| _element.is_a?(Hash) ? self.class.facet_factory(_element) : _element end super(mapped_values) end end |
#queries=(value) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/skala/adapter/search/request.rb', line 53 def queries=(value) if sanitized_value = [value].flatten(1).compact.presence mapped_values = sanitized_value.map do |_element| _element.is_a?(Hash) ? self.class.query_factory(_element) : _element end super(mapped_values) end end |
#to_param ⇒ Object
TODO: move to frontend
87 88 89 90 |
# File 'lib/skala/adapter/search/request.rb', line 87 def to_param(*) # binding.pry to_json end |