Module: Switchman::ActiveRecord::AbstractAdapter

Defined in:
lib/switchman/active_record/abstract_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_query_atObject (readonly)

Returns the value of attribute last_query_at.



7
8
9
# File 'lib/switchman/active_record/abstract_adapter.rb', line 7

def last_query_at
  @last_query_at
end

#shardObject



9
10
11
# File 'lib/switchman/active_record/abstract_adapter.rb', line 9

def shard
  @shard || Shard.default
end

Instance Method Details

#dump_schema_informationObject

:nodoc:



26
27
28
29
30
# File 'lib/switchman/active_record/abstract_adapter.rb', line 26

def dump_schema_information #:nodoc:
  sm_table = ::ActiveRecord::Migrator.schema_migrations_table_name
  migrated = select_values("SELECT version FROM #{quote_table_name(sm_table)} ORDER BY version")
  migrated.map { |v| "INSERT INTO #{quote_table_name(sm_table)} (version) VALUES ('#{v}');" }.join("\n\n")
end

#initialize(*args) ⇒ Object



13
14
15
16
17
# File 'lib/switchman/active_record/abstract_adapter.rb', line 13

def initialize(*args)
  super
  @instrumenter = Switchman::ShardedInstrumenter.new(@instrumenter, self)
  @last_query_at = Time.now
end

#log(*args, &block) ⇒ Object



19
20
21
22
23
# File 'lib/switchman/active_record/abstract_adapter.rb', line 19

def log(*args, &block)
  super
ensure
  @last_query_at = Time.now
end