Module: Octopus::AssociationCollection

Defined in:
lib/octopus/association_collection.rb

Instance Method Summary collapse

Instance Method Details

#count(*args) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/octopus/association_collection.rb', line 6

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

#should_wrap_the_connection?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/octopus/association_collection.rb', line 2

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