Sha256: 9991b03955518753e0a7107e220bb6e6ee75e9db5f175f1180e2e2b6ffd52473

Contents?: true

Size: 1.26 KB

Versions: 19

Compression:

Stored size: 1.26 KB

Contents

module ActiveRecord
  module ConnectionAdapters
    class JdbcColumn < Column
      attr_writer :limit, :precision

      def initialize(config, name, default, *args)
        call_discovered_column_callbacks(config)
        super(name,default_value(default),*args)
        init_column(name, default, *args)
      end

      def init_column(*args)
      end

      def default_value(val)
        val
      end

      def self.column_types
        # GH #25: reset the column types if the # of constants changed
        # since last call
        if ::ArJdbc.constants.size != driver_constants.size
          @driver_constants = nil
          @column_types = nil
        end
        @column_types ||= driver_constants.select {|c|
          c.respond_to? :column_selector }.map {|c|
          c.column_selector }.inject({}) {|h,val|
          h[val[0]] = val[1]; h }
      end

      def self.driver_constants
        @driver_constants ||= ::ArJdbc.constants.map {|c| ::ArJdbc.const_get c }
      end

      protected
      def call_discovered_column_callbacks(config)
        dialect = config[:dialect] || config[:driver]
        for reg, func in JdbcColumn.column_types
          if reg === dialect.to_s
            func.call(config,self)
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
cmoran92-activerecord-jdbc-adapter-1.2.1.2 lib/arjdbc/jdbc/column.rb
activerecord-jdbc-adapter-1.2.5 lib/arjdbc/jdbc/column.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.5 lib/arjdbc/jdbc/column.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.4 lib/arjdbc/jdbc/column.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.3 lib/arjdbc/jdbc/column.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.2 lib/arjdbc/jdbc/column.rb
activerecord-jdbc-adapter-1.2.2.1 lib/arjdbc/jdbc/column.rb
activerecord-jdbc-adapter-onsite-1.2.2 lib/arjdbc/jdbc/column.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.1 lib/arjdbc/jdbc/column.rb
activerecord-jdbc-adapter-1.2.2 lib/arjdbc/jdbc/column.rb
cmoran92-activerecord-jdbc-adapter-1.2.1 lib/arjdbc/jdbc/column.rb
activerecord-jdbc-adapter-1.2.1 lib/arjdbc/jdbc/column.rb
c3-activerecord-jdbc-adapter-1.1.3.1 lib/arjdbc/jdbc/column.rb
activerecord-jdbc-adapter-1.2.0 lib/arjdbc/jdbc/column.rb
c3-activerecord-jdbc-adapter-1.1.3 lib/arjdbc/jdbc/column.rb
jashmenn-activerecord-jdbc-adapter-1.2.0.0 lib/arjdbc/jdbc/column.rb
jashmenn-activerecord-jdbc-adapter-1.2.0 lib/arjdbc/jdbc/column.rb
activerecord-jdbc-adapter-1.1.3 lib/arjdbc/jdbc/column.rb
activerecord-jdbc-adapter-1.1.2 lib/arjdbc/jdbc/column.rb