Class: DBI::Type::Boolean
Overview
Represents a SQL BOOLEAN. Returns true/false. Falls back to Null.
Class Method Summary collapse
Class Method Details
.parse(obj) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/dbi/types.rb', line 127 def self.parse(obj) obj = super return nil if obj.nil? if obj == false or obj.kind_of? FalseClass return false elsif obj.kind_of? TrueClass return true else case obj when 't' return true when 'f' return false end if obj.respond_to? :to_i if obj.to_i == 0 return false else return true end else # punt return nil end end end |