Class: Sunspot::Type::BooleanType

Inherits:
AbstractType show all
Defined in:
sunspot/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

- (Object) cast(string)

:nodoc:



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

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

- (Object) indexed_name(name)

:nodoc:



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

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

- (Object) to_indexed(value)

:nodoc:



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

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