Class: Sunspot::Type::CaseInsensitiveSortType

Inherits:
StringType
  • Object
show all
Defined in:
lib/sunspot_plus/type/case_insensitive_sort_type.rb

Overview

The CaseInsensitiveSort type represents string data optimised for case insensitve search.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.patternObject



9
10
11
# File 'lib/sunspot_plus/type/case_insensitive_sort_type.rb', line 9

def pattern
  @@pattern
end

.pattern=(value) ⇒ Object



13
14
15
# File 'lib/sunspot_plus/type/case_insensitive_sort_type.rb', line 13

def pattern=(value)
  @@pattern=value
end

Instance Method Details

#field_name(name) ⇒ Object



28
29
30
# File 'lib/sunspot_plus/type/case_insensitive_sort_type.rb', line 28

def field_name(name)
  "case_insensitive_sort_#{name}"
end

#indexed_name(name) ⇒ Object

:nodoc:



24
25
26
# File 'lib/sunspot_plus/type/case_insensitive_sort_type.rb', line 24

def indexed_name(name) #:nodoc:
  "#{name}_s"
end

#patternObject



20
21
22
# File 'lib/sunspot_plus/type/case_insensitive_sort_type.rb', line 20

def pattern
  self.class.pattern
end

#to_indexed(value) ⇒ Object

:nodoc:



32
33
34
35
36
37
38
39
40
# File 'lib/sunspot_plus/type/case_insensitive_sort_type.rb', line 32

def to_indexed(value) #:nodoc:
  if value
    if pattern.is_a?(Symbol)
      value.to_s.send(pattern) 
    elsif pattern.is_a?(Proc)
      pattern.call(value)
    end
  end
end