| Class | Amalgalite::Boolean |
| In: |
lib/amalgalite/boolean.rb
|
| Parent: | Object |
Do type conversion on values that could be boolen values into real ‘true’ or ‘false‘
This is pulled from the possible boolean values from PostgreSQL
list of downcased strings are potential false values
# File lib/amalgalite/boolean.rb, line 24
24: def false_values
25: @false_values ||= %w[ false f no n 0 ]
26: end
Convert val to a string and attempt to convert it to true or false
# File lib/amalgalite/boolean.rb, line 31
31: def to_bool( val )
32: return false if val.nil?
33: unless @to_bool
34: @to_bool = {}
35: true_values.each { |t| @to_bool[t] = true }
36: false_values.each { |f| @to_bool[f] = false }
37: end
38: return @to_bool[val.to_s.downcase]
39: end