module Tako::ActiveRecordExt::Base::InstanceMethods

Attributes

current_shard[RW]

Public Class Methods

included(mod) click to toggle source
# File lib/tako/active_record_ext/base.rb, line 30
def self.included(mod)
  mod.extend(ShardedMethods)
  mod.sharded_methods :update_attribute,
                      :update_attributes,
                      :update_attributes!,
                      :reload,
                      :delete,
                      :destroy,
                      :touch,
                      :update_column,
                      :save,
                      :save!

  mod.class_eval do
    after_initialize :set_current_shard

    private

      def set_current_shard
        @current_shard = ::Tako::ProxyStack.top.try(:shard_name)
      end
  end
end

Public Instance Methods

set_current_shard() click to toggle source
# File lib/tako/active_record_ext/base.rb, line 48
def set_current_shard
  @current_shard = ::Tako::ProxyStack.top.try(:shard_name)
end