Module: ArJdbc::Oracle::Column::Cast
- Defined in:
- lib/arjdbc/oracle/column.rb
Instance Method Summary collapse
- #string_to_time(string) ⇒ Object
-
#value_to_boolean(value) ⇒ Object
Convert a value to a boolean.
Instance Method Details
#string_to_time(string) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/arjdbc/oracle/column.rb', line 103 def string_to_time(string) return string unless string.is_a?(String) return nil if string.empty? return Time.now if string.index('CURRENT') == 0 # TODO seems very wrong super(string) end |
#value_to_boolean(value) ⇒ Object
Convert a value to a boolean.
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/arjdbc/oracle/column.rb', line 90 def value_to_boolean(value) # NOTE: Oracle JDBC meta-data gets us DECIMAL for NUMBER(1) values # thus we're likely to get a column back as BigDecimal (e.g. 1.0) if value.is_a?(String) value.blank? ? nil : value == '1' elsif value.is_a?(Numeric) value.to_i == 1 # <BigDecimal:7b5bfe,'0.1E1',1(4)> else !! value end end |