Sha256: 20afd1b665951861831d30fd164870ee2ece335d522b9d72f4b87d625a32e1cb

Contents?: true

Size: 403 Bytes

Versions: 17

Compression:

Stored size: 403 Bytes

Contents

module Octopus::AssociationCollection   
  def should_wrap_the_connection?
    @owner.respond_to?(:current_shard) && @owner.current_shard != nil
  end

  def count(*args)
    if should_wrap_the_connection?
      Octopus.using(@owner.current_shard) { super } 
    else        
      super
    end
  end
end

ActiveRecord::Associations::AssociationCollection.send(:include, Octopus::AssociationCollection)

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ar-octopus-0.4.0 lib/octopus/association_collection.rb
ar-octopus-0.3.4 lib/octopus/association_collection.rb
ar-octopus-0.3.3 lib/octopus/association_collection.rb
ar-octopus-0.3.2 lib/octopus/association_collection.rb
ar-octopus-0.3.1 lib/octopus/association_collection.rb
ar-octopus-0.3.0 lib/octopus/association_collection.rb
ar-octopus-0.2.2 lib/octopus/association_collection.rb
ar-octopus-0.2.1 lib/octopus/association_collection.rb
ar-octopus-0.2.0 lib/octopus/association_collection.rb
ar-octopus-0.1.2 lib/octopus/association_collection.rb
ar-octopus-0.1.1 lib/octopus/association_collection.rb
ar-octopus-0.1.0 lib/octopus/association_collection.rb
ar-octopus-0.0.30 lib/octopus/association_collection.rb
ar-octopus-0.0.29 lib/octopus/association_collection.rb
ar-octopus-0.0.28 lib/octopus/association_collection.rb
ar-octopus-0.0.27 lib/octopus/association_collection.rb
ar-octopus-0.0.26 lib/octopus/association_collection.rb