Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
Class Method Summary collapse
-
.ignore_table_columns(*args) ⇒ Object
Specify table columns which should be ignored by ActiveRecord, e.g.:.
- .lob_columns ⇒ Object
-
.set_boolean_columns(*args) ⇒ Object
Specify which table columns should be typecasted to boolean values
true
orfalse
, e.g.:. -
.set_date_columns(*args) ⇒ Object
Specify which table columns should be typecasted to Date (without time), e.g.:.
-
.set_datetime_columns(*args) ⇒ Object
Specify which table columns should be typecasted to Time (or DateTime), e.g.:.
-
.set_integer_columns(*args) ⇒ Object
Specify which table columns should be typecasted to integer values.
-
.set_string_columns(*args) ⇒ Object
Specify which table columns should be typecasted to string values.
-
.table_comment ⇒ Object
Get table comment from schema definition.
- .virtual_columns ⇒ Object
Instance Method Summary collapse
Class Method Details
.ignore_table_columns(*args) ⇒ Object
Specify table columns which should be ignored by ActiveRecord, e.g.:
ignore_table_columns :attribute1, :attribute2
55 56 57 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 55 def self.ignore_table_columns(*args) connection.ignore_table_columns(table_name,*args) end |
.lob_columns ⇒ Object
102 103 104 105 106 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 102 def self.lob_columns columns.select do |column| column.respond_to?(:lob?) && column.lob? end end |
.set_boolean_columns(*args) ⇒ Object
Specify which table columns should be typecasted to boolean values true
or false
, e.g.:
set_boolean_columns :is_valid, :is_completed
76 77 78 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 76 def self.set_boolean_columns(*args) connection.set_type_for_columns(table_name,:boolean,*args) end |
.set_date_columns(*args) ⇒ Object
Specify which table columns should be typecasted to Date (without time), e.g.:
set_date_columns :created_on, :updated_on
62 63 64 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 62 def self.set_date_columns(*args) connection.set_type_for_columns(table_name,:date,*args) end |
.set_datetime_columns(*args) ⇒ Object
Specify which table columns should be typecasted to Time (or DateTime), e.g.:
set_datetime_columns :created_date, :updated_date
69 70 71 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 69 def self.set_datetime_columns(*args) connection.set_type_for_columns(table_name,:datetime,*args) end |
.set_integer_columns(*args) ⇒ Object
Specify which table columns should be typecasted to integer values. Might be useful to force NUMBER(1) column to be integer and not boolean, or force NUMBER column without scale to be retrieved as integer and not decimal. Example:
set_integer_columns :version_number, :object_identifier
85 86 87 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 85 def self.set_integer_columns(*args) connection.set_type_for_columns(table_name,:integer,*args) end |
.set_string_columns(*args) ⇒ Object
Specify which table columns should be typecasted to string values. Might be useful to specify that columns should be string even if its name matches boolean column criteria.
set_string_columns :active_flag
93 94 95 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 93 def self.set_string_columns(*args) connection.set_type_for_columns(table_name,:string,*args) end |
.table_comment ⇒ Object
Get table comment from schema definition.
98 99 100 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 98 def self.table_comment connection.table_comment(self.table_name) end |
.virtual_columns ⇒ Object
108 109 110 111 112 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 108 def self.virtual_columns columns.select do |column| column.respond_to?(:virtual?) && column.virtual? end end |
Instance Method Details
#arel_attributes_with_values(attribute_names) ⇒ Object
114 115 116 117 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 114 def arel_attributes_with_values(attribute_names) virtual_column_names = self.class.virtual_columns.map(&:name) super(attribute_names - virtual_column_names) end |