Class: ActiveRecord::ConnectionAdapters::OracleEnhancedColumn

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

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

:nodoc:



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

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

Instance Attribute Details

#forced_column_typeObject (readonly)

:nodoc:



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

def forced_column_type
  @forced_column_type
end

#table_nameObject (readonly)

:nodoc:



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

def table_name
  @table_name
end

Class Method Details

.string_to_date(string) ⇒ Object

convert Time or DateTime value to Date for :date columns



172
173
174
175
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 172

def self.string_to_date(string) #:nodoc:
  return string.to_date if string.is_a?(Time) || string.is_a?(DateTime)
  super
end

.string_to_time(string) ⇒ Object

convert Date value to Time for :datetime columns



178
179
180
181
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 178

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

.value_to_boolean(value) ⇒ Object

convert something to a boolean added y as boolean value



161
162
163
164
165
166
167
168
169
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 161

def self.value_to_boolean(value) #:nodoc:
  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

Get column comment from schema definition. Will work only if using default ActiveRecord connection.



185
186
187
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 185

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

#type_cast(value) ⇒ Object

:nodoc:



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

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