Module: Switchman::ActiveRecord::AbstractAdapter

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

Instance Attribute Summary collapse

Class Method 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

Class Method Details

.included(klass) ⇒ Object



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

def self.included(klass)
  klass.alias_method_chain :initialize, :shard
  klass.alias_method_chain :log, :timestamp
end

Instance Method Details

#initialize_with_shard(*args) ⇒ Object



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

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

#log_with_timestamp(*args, &block) ⇒ Object



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

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