Class: ActiveRecord::ConnectionAdapters::JdbcColumn
- Inherits:
-
Column
- Object
- Column
- ActiveRecord::ConnectionAdapters::JdbcColumn
- Defined in:
- lib/arjdbc/jdbc/column.rb
Overview
The base class for all of JdbcAdapter's returned columns.
Instances of JdbcColumn will get extended with "column-spec" modules
(similar to how JdbcAdapter gets spec modules in) if the adapter spec
module provided a column_selector
(matcher) method for it's database
specific type.
Direct Known Subclasses
DB2Column, FirebirdColumn, MSSQLColumn, OracleColumn, SQLite3Column
Instance Attribute Summary collapse
-
#limit ⇒ Object
writeonly
deprecated
Deprecated.
attribute writers will be removed in 1.4
-
#precision ⇒ Object
writeonly
deprecated
Deprecated.
attribute writers will be removed in 1.4
Class Method Summary collapse
-
.column_types ⇒ Hash
Returns the available column types.
Instance Method Summary collapse
-
#default_value(value) ⇒ Object
Similar to
ActiveRecord
'sextract_value_from_default(default)
. -
#init_column(*args) ⇒ Object
Additional column initialization for sub-classes.
-
#initialize(config, name, *args) ⇒ JdbcColumn
constructor
A new instance of JdbcColumn.
Constructor Details
#initialize(config, name, *args) ⇒ JdbcColumn
Returns a new instance of JdbcColumn.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/arjdbc/jdbc/column.rb', line 18 def initialize(config, name, *args) if self.class == JdbcColumn # NOTE: extending classes do not want this if they do they shall call call_discovered_column_callbacks(config) if config default = args.shift else # for extending classes allow ignoring first argument : if ! config.nil? && ! config.is_a?(Hash) default = name; name = config # initialize(name, default, *args) else default = args.shift end end if ArJdbc::AR52 # undefined method `cast' for #<ActiveRecord::ConnectionAdapters::SqlTypeMetadata> on AR52 else default = args[0].cast(default) sql_type = args.delete_at(1) type = args.delete_at(0) args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type)) end # super <= 4.1: (name, default, sql_type = nil, null = true) # super >= 4.2: (name, default, cast_type, sql_type = nil, null = true) # super >= 5.0: (name, default, sql_type_metadata = nil, null = true) super(name, default, *args) init_column(name, default, *args) end |
Instance Attribute Details
#limit=(value) ⇒ Object (writeonly)
attribute writers will be removed in 1.4
16 17 18 |
# File 'lib/arjdbc/jdbc/column.rb', line 16 def limit=(value) @limit = value end |
#precision=(value) ⇒ Object (writeonly)
attribute writers will be removed in 1.4
16 17 18 |
# File 'lib/arjdbc/jdbc/column.rb', line 16 def precision=(value) @precision = value end |
Class Method Details
.column_types ⇒ Hash
Returns the available column types
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/arjdbc/jdbc/column.rb', line 71 def self.column_types types = {} for mod in ::ArJdbc.modules if mod.respond_to?(:column_selector) sel = mod.column_selector # [ matcher, block ] types[ sel[0] ] = sel[1] end end types end |
Instance Method Details
#default_value(value) ⇒ Object
Similar to ActiveRecord
's extract_value_from_default(default)
.
55 |
# File 'lib/arjdbc/jdbc/column.rb', line 55 def default_value(value); value; end |
#init_column(*args) ⇒ Object
Additional column initialization for sub-classes.
51 |
# File 'lib/arjdbc/jdbc/column.rb', line 51 def init_column(*args); end |