module Rails::Sharding::ActiveRecordExtensions
Public Class Methods
extend_active_record_scope()
click to toggle source
Will automatically add the using_shard
method to all ActiveRecord scopes (including has_many and habtm relations).
Despite the fact that the using_shard
method will exist for all scopes, it will only have effect when loading/saving models that include the Rails::Sharding::Shardable module
# File lib/rails/sharding/active_record_extensions.rb, line 10 def self.extend_active_record_scope # avoinds duplicate extension return if ActiveRecord::Base.respond_to? :using_shard # Includes #using_shard in ActiveRecord::Base models (both classes and instances) ActiveRecord::Base.extend ScopeMethods ActiveRecord::Base.include ScopeMethods ActiveRecord::Base.extend CaseFixer # Includes #using_shard scope method in scopes ActiveRecord::Relation.include ScopeMethods ActiveRecord::Relation.extend CaseFixer # Includes #using_shard scope method in has_many and habtm relations ActiveRecord::Scoping.include ScopeMethods ActiveRecord::Scoping.extend CaseFixer end