Class: Elasticsearch::FacetedSearch::FacetItem
- Inherits:
-
Object
- Object
- Elasticsearch::FacetedSearch::FacetItem
- Extended by:
- Forwardable
- Defined in:
- lib/elasticsearch/faceted_search/facet_item.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
Returns the value of attribute group.
-
#object ⇒ Object
Returns the value of attribute object.
Instance Method Summary collapse
-
#id ⇒ Object
delegate :operator_mappings, :operator, :key, :selected_values, :group_params, :type, to: :group delegate :term, :count, to: :object.
-
#initialize(group, object) ⇒ FacetItem
constructor
A new instance of FacetItem.
- #params_for ⇒ Object
- #selected? ⇒ Boolean
Constructor Details
#initialize(group, object) ⇒ FacetItem
Returns a new instance of FacetItem.
19 20 21 22 |
# File 'lib/elasticsearch/faceted_search/facet_item.rb', line 19 def initialize(group, object) self.group = group self.object = OpenStruct.new(object) end |
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
8 9 10 |
# File 'lib/elasticsearch/faceted_search/facet_item.rb', line 8 def group @group end |
#object ⇒ Object
Returns the value of attribute object.
8 9 10 |
# File 'lib/elasticsearch/faceted_search/facet_item.rb', line 8 def object @object end |
Instance Method Details
#id ⇒ Object
delegate :operator_mappings, :operator, :key, :selected_values, :group_params, :type, to: :group delegate :term, :count, to: :object
15 16 17 |
# File 'lib/elasticsearch/faceted_search/facet_item.rb', line 15 def id object.id.to_s end |
#params_for ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/elasticsearch/faceted_search/facet_item.rb', line 28 def params_for prefix = selected? ? :remove : :add case type when 'multivalue' then send(:"#{prefix}_multivalue") when 'multivalue_and' then send(:"#{prefix}_multivalue", :and) when 'multivalue_or' then send(:"#{prefix}_multivalue", :or) when 'exclusive_or' then send(:"#{prefix}_singlevalue") # else raise UnknownSelectableType.new "Unknown selectable type #{selectable_type} for #{@type}" end end |
#selected? ⇒ Boolean
24 25 26 |
# File 'lib/elasticsearch/faceted_search/facet_item.rb', line 24 def selected? @selected ||= Array(group_params).include?(id) end |