Module: ShardedDatabase::Aggregate::InstanceMethods

Defined in:
lib/sharded_database/aggregate.rb

Instance Method Summary collapse

Instance Method Details

#after_findObject



56
57
58
59
60
61
62
63
64
# File 'lib/sharded_database/aggregate.rb', line 56

def after_find
  @klass      = sharded_connection_klass
  @connection = @klass.respond_to?(:connection) ? @klass.connection : raise(ShardedDatabase::NoConnectionError, 'Connection class does not respond to :connection')
  @foreign_id = self[self.class.foreign_id.to_sym]
  
  preserve_attributes
  apply_proxy
  channel_associations_to_proper_connection
end

#sharded_connection_klassObject

Raises:

  • (NotImplementedError)


51
52
53
54
# File 'lib/sharded_database/aggregate.rb', line 51

def sharded_connection_klass
  raise NotImplementedError,
    "You must implement your own #sharded_connection_klass method that returns an ActiveRecord::Base subclass which yeilds a connection."
end