Sha256: 25c7f46baf3e9a57502ba3e46736186418d15181695884f35dceb07a17da42dc

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

module ContactFakeColumns
  def self.extended(base)
    base.class_eval do
      establish_connection(:adapter => 'fake')

      connection.data_sources = [table_name]
      connection.primary_keys = {
        table_name => 'id'
      }

      column :id,             :integer
      column :name,           :string
      column :age,            :integer
      column :avatar,         :binary
      column :created_at,     :datetime
      column :awesome,        :boolean
      column :preferences,    :string
      column :alternative_id, :integer

      serialize :preferences

      belongs_to :alternative, :class_name => 'Contact'
    end
  end

  # mock out self.columns so no pesky db is needed for these tests
  def column(name, sql_type = nil, options = {})
    connection.merge_column(table_name, name, sql_type, options)
  end
end

class Contact < ActiveRecord::Base
  extend ContactFakeColumns
end

class ContactSti < ActiveRecord::Base
  extend ContactFakeColumns
  column :type, :string

  def type; 'ContactSti' end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ibm_db-5.2.0 test/models/contact.rb
ibm_db-5.1.0 test/models/contact.rb
ibm_db-5.0.5 test/models/contact.rb
ibm_db-5.0.4 test/models/contact.rb
ibm_db-5.0.3 test/models/contact.rb
ibm_db-5.0.2 test/models/contact.rb
ibm_db-4.0.0-x86-mingw32 test/models/contact.rb
ibm_db-4.0.0 test/models/contact.rb