Class: ActiveRecord::ConnectionAdapters::JdbcColumn
- Inherits:
-
Column
- Object
- Column
- ActiveRecord::ConnectionAdapters::JdbcColumn
- Defined in:
- lib/jdbc_adapter/jdbc_sqlite3.rb,
lib/active_record/connection_adapters/jdbc_adapter.rb
Constant Summary collapse
- COLUMN_TYPES =
::JdbcSpec.constants.map{|c| ::JdbcSpec.const_get c }.select{ |c| c.respond_to? :column_selector }.map{|c| c.column_selector }.inject({}) { |h,val| h[val[0]] = val[1]; h }
Instance Attribute Summary collapse
-
#limit ⇒ Object
writeonly
Sets the attribute limit.
-
#precision ⇒ Object
writeonly
Sets the attribute precision.
Class Method Summary collapse
Instance Method Summary collapse
- #default_value(val) ⇒ Object
- #init_column(*args) ⇒ Object
-
#initialize(config, name, default, *args) ⇒ JdbcColumn
constructor
A new instance of JdbcColumn.
Constructor Details
#initialize(config, name, default, *args) ⇒ JdbcColumn
Returns a new instance of JdbcColumn.
294 295 296 297 298 299 300 301 302 303 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 294 def initialize(config, name, default, *args) dialect = config[:dialect] || config[:driver] for reg, func in COLUMN_TYPES if reg === dialect.to_s func.call(config,self) end end super(name,default_value(default),*args) init_column(name, default, *args) end |
Instance Attribute Details
#limit=(value) ⇒ Object (writeonly)
Sets the attribute limit
286 287 288 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 286 def limit=(value) @limit = value end |
#precision=(value) ⇒ Object (writeonly)
Sets the attribute precision
286 287 288 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 286 def precision=(value) @precision = value end |
Class Method Details
.binary_to_string(value) ⇒ Object
376 377 378 379 380 381 382 383 |
# File 'lib/jdbc_adapter/jdbc_sqlite3.rb', line 376 def self.binary_to_string(value) value.gsub(/%00|%25/n) do |b| case b when "%00" then "\0" when "%25" then "%" end end end |
.string_to_binary(value) ⇒ Object
367 368 369 370 371 372 373 374 |
# File 'lib/jdbc_adapter/jdbc_sqlite3.rb', line 367 def self.string_to_binary(value) value.gsub(/\0|%/n) do |b| case b when "\0" then "%00" when "\%" then "%25" end end end |
Instance Method Details
#default_value(val) ⇒ Object
308 309 310 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 308 def default_value(val) val end |
#init_column(*args) ⇒ Object
305 306 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 305 def init_column(*args) end |