Class: Sunspot::Search::JsonFacetRow

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/search/json_facet_row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, facet) ⇒ JsonFacetRow

:nodoc:



7
8
9
10
11
12
13
# File 'lib/sunspot/search/json_facet_row.rb', line 7

def initialize(data, facet) #:nodoc:
  @value = data['val']
  @count = data['distinct'] || data['count']
  @facet = facet
  @nested_key = data.keys.select { |k| data[k].is_a?(Hash) }.first
  @nested = recursive_nested_initialization(data) unless @nested_key.nil?
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



4
5
6
# File 'lib/sunspot/search/json_facet_row.rb', line 4

def count
  @count
end

#instanceObject

Return the instance referenced by this facet row. Only valid for field facets whose fields are defined with the :references key.



19
20
21
22
23
24
# File 'lib/sunspot/search/json_facet_row.rb', line 19

def instance
  if !defined?(@instance)
    @facet.populate_instances
  end
  @instance
end

#nestedObject (readonly)

Returns the value of attribute nested.



4
5
6
# File 'lib/sunspot/search/json_facet_row.rb', line 4

def nested
  @nested
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/sunspot/search/json_facet_row.rb', line 4

def value
  @value
end

Instance Method Details

#inspectObject



26
27
28
# File 'lib/sunspot/search/json_facet_row.rb', line 26

def inspect
  "<Sunspot::Search::FacetRow:#{value.inspect} (#{count}) #{nested.nil? ? '' : " nested_count=#{nested.size}"}>"
end