Class: Sunspot::FacetData::Abstract

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

Overview

Base class for facet data.

Direct Known Subclasses

FieldFacetData, QueryFacetData

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fieldObject (readonly)

:nodoc:



14
15
16
# File 'lib/sunspot/facet_data.rb', line 14

def field
  @field
end

Instance Method Details

#cast(value) ⇒ Object

Cast the given value to the field’s type, if it has one; otherwise just return the string.



27
28
29
30
31
32
33
# File 'lib/sunspot/facet_data.rb', line 27

def cast(value)
  if @field
    @field.cast(value)
  else
    value
  end
end

#referenceObject

The class that the field references, if any.



19
20
21
# File 'lib/sunspot/facet_data.rb', line 19

def reference
  @field.reference if @field
end

#row_value(value) ⇒ Object

Given the raw facet row value, return what the Sunspot facet row object should present as the value. This can be overridden by subclasses.



39
40
41
# File 'lib/sunspot/facet_data.rb', line 39

def row_value(value)
  cast(value)
end