Module: ArJdbc::Oracle::Column
- Defined in:
- lib/arjdbc/oracle/adapter.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.guess_date_or_time(value) ⇒ Object
70 71 72 73 |
# File 'lib/arjdbc/oracle/adapter.rb', line 70 def self.guess_date_or_time(value) (value && value.hour == 0 && value.min == 0 && value.sec == 0) ? Date.new(value.year, value.month, value.day) : value end |
.string_to_time(string, klass) ⇒ Object
65 66 67 68 |
# File 'lib/arjdbc/oracle/adapter.rb', line 65 def self.string_to_time(string, klass) time = klass.string_to_time(string) guess_date_or_time(time) end |
Instance Method Details
#primary=(val) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/arjdbc/oracle/adapter.rb', line 41 def primary=(val) super if val && @sql_type =~ /^NUMBER$/i @type = :integer end end |
#type_cast(value) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/arjdbc/oracle/adapter.rb', line 48 def type_cast(value) return nil if value.nil? case type when :datetime then ArJdbc::Oracle::Column.string_to_time(value, self.class) else super end end |
#type_cast_code(var_name) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/arjdbc/oracle/adapter.rb', line 57 def type_cast_code(var_name) case type when :datetime then "ArJdbc::Oracle::Column.string_to_time(#{var_name}, self.class)" else super end end |