Class: Sunspot::Type::BooleanType

Inherits:
AbstractType show all
Defined in:
lib/sunspot/type.rb

Overview

The boolean type represents true/false values. Note that nil will not be indexed at all; only false will be indexed with a false value.

Instance Method Summary collapse

Methods inherited from AbstractType

#accepts_dynamic?, #accepts_more_like_this?, instance, #to_literal

Instance Method Details

#cast(string) ⇒ Object

:nodoc:



314
315
316
317
318
319
320
321
322
323
# File 'lib/sunspot/type.rb', line 314

def cast(string) #:nodoc:
  case string
  when 'true'
    true
  when 'false'
    false
  when true, false
    string
  end
end

#indexed_name(name) ⇒ Object

:nodoc:



304
305
306
# File 'lib/sunspot/type.rb', line 304

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

#to_indexed(value) ⇒ Object

:nodoc:



308
309
310
311
312
# File 'lib/sunspot/type.rb', line 308

def to_indexed(value) #:nodoc:
  unless value.nil?
    value ? 'true' : 'false'
  end
end