Class: Mongomatic::TypeConverters::Bool

Inherits:
Base
  • Object
show all
Defined in:
lib/mongomatic/type_converters.rb

Instance Method Summary collapse

Methods inherited from Base

#cast, #initialize

Constructor Details

This class inherits a constructor from Mongomatic::TypeConverters::Base

Instance Method Details

#convert_orig_valObject



89
90
91
92
93
94
95
96
97
98
# File 'lib/mongomatic/type_converters.rb', line 89

def convert_orig_val
  s_val = @orig_val.to_s.downcase
  if %w(1 t true y yes).include?(s_val)
    true
  elsif %w(0 f false n no).include?(s_val)
    false
  else
    nil
  end
end

#type_match?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/mongomatic/type_converters.rb', line 85

def type_match?
  @orig_val == true || @orig_val == false
end