Class: ActiveRecord::ConnectionAdapters::OracleEnhancedColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/active_record/connection_adapters/oracle_enhanced_adapter.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, default, sql_type = nil, null = true, table_name = nil, forced_column_type = nil) ⇒ OracleEnhancedColumn

Returns a new instance of OracleEnhancedColumn.



117
118
119
120
121
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 117

def initialize(name, default, sql_type = nil, null = true, table_name = nil, forced_column_type = nil)
  @table_name = table_name
  @forced_column_type = forced_column_type
  super(name, default, sql_type, null)
end

Instance Attribute Details

#forced_column_typeObject (readonly)

Returns the value of attribute forced_column_type.



115
116
117
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 115

def forced_column_type
  @forced_column_type
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



115
116
117
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 115

def table_name
  @table_name
end

Class Method Details

.string_to_date(string) ⇒ Object

RSI: convert Time value to Date for :date columns



141
142
143
144
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 141

def self.string_to_date(string)
  return string.to_date if string.is_a?(Time)
  super
end

.string_to_time(string) ⇒ Object

RSI: convert Date value to Time for :datetime columns



147
148
149
150
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 147

def self.string_to_time(string)
  return string.to_time if string.is_a?(Date) && !OracleEnhancedAdapter.emulate_dates
  super
end

.value_to_boolean(value) ⇒ Object

convert something to a boolean RSI: added y as boolean value



130
131
132
133
134
135
136
137
138
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 130

def self.value_to_boolean(value)
  if value == true || value == false
    value
  elsif value.is_a?(String) && value.blank?
    nil
  else
    %w(true t 1 y +).include?(value.to_s.downcase)
  end
end

Instance Method Details

#commentObject

RSI: get column comment from schema definition will work only if using default ActiveRecord connection



154
155
156
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 154

def comment
  ActiveRecord::Base.connection.column_comment(@table_name, name)
end

#type_cast(value) ⇒ Object



123
124
125
126
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 123

def type_cast(value)
  return guess_date_or_time(value) if type == :datetime && OracleEnhancedAdapter.emulate_dates
  super
end