Module: Rails::Sharding::ActiveRecordExtensions
- Defined in:
- lib/rails/sharding/active_record_extensions.rb
Defined Under Namespace
Modules: CaseFixer, ScopeMethods Classes: ScopeProxy
Class Method Summary collapse
-
.extend_active_record_scope ⇒ Object
Will automatically add the #using_shard method to all ActiveRecord scopes (including has_many and habtm relations).
Class Method Details
.extend_active_record_scope ⇒ Object
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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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 |