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?, #to_literal

Instance Method Details

#cast(string) ⇒ Object

:nodoc:



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

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

#indexed_name(name) ⇒ Object

:nodoc:



306
307
308
# File 'lib/sunspot/type.rb', line 306

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

#to_indexed(value) ⇒ Object

:nodoc:



310
311
312
313
314
# File 'lib/sunspot/type.rb', line 310

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