Module: Octopus::ShardTracking::Attribute

Included in:
RelationProxy, Octopus::ScopeProxy
Defined in:
lib/octopus/shard_tracking/attribute.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_shardObject

Returns the value of attribute current_shard


11
12
13
# File 'lib/octopus/shard_tracking/attribute.rb', line 11

def current_shard
  @current_shard
end

Class Method Details

.included(base) ⇒ Object


7
8
9
# File 'lib/octopus/shard_tracking/attribute.rb', line 7

def self.included(base)
  base.send(:include, Octopus::ShardTracking)
end

Instance Method Details

#set_current_shardObject


13
14
15
16
17
18
19
# File 'lib/octopus/shard_tracking/attribute.rb', line 13

def set_current_shard
  return unless Octopus.enabled?

  if ActiveRecord::Base.connection_proxy.block
    self.current_shard = ActiveRecord::Base.connection_proxy.current_shard
  end
end