module Switchman::ActiveRecord::AbstractAdapter

Attributes

last_query_at[R]
shard[W]

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/switchman/active_record/abstract_adapter.rb, line 22
def initialize(*args)
  super
  @instrumenter = Switchman::ShardedInstrumenter.new(@instrumenter, self)
  @last_query_at = Time.now
end

Public Instance Methods

quote_local_table_name(name) click to toggle source
# File lib/switchman/active_record/abstract_adapter.rb, line 28
def quote_local_table_name(name)
  quote_table_name(name)
end
schema_migration() click to toggle source
# File lib/switchman/active_record/abstract_adapter.rb, line 32
def schema_migration
  ::ActiveRecord::SchemaMigration
end
shard() click to toggle source
# File lib/switchman/active_record/abstract_adapter.rb, line 18
def shard
  @shard || Shard.default
end

Protected Instance Methods

log(*args, &block) click to toggle source
Calls superclass method
# File lib/switchman/active_record/abstract_adapter.rb, line 38
def log(*args, &block)
  super
ensure
  @last_query_at = Time.now
end

Private Instance Methods

id_value_for_database(value) click to toggle source
Calls superclass method
# File lib/switchman/active_record/abstract_adapter.rb, line 46
def id_value_for_database(value)
  return super unless value.class.sharded_primary_key?

  # do this the Rails 4.2 way, so that if Shard.current != self.shard, the id gets transposed
  quote(value.id)
end