Module: ShardedDatabase::ModelWithConnection::ClassMethods
- Defined in:
- lib/sharded_database/model_with_connection.rb
Instance Method Summary collapse
Instance Method Details
#find_with_connection(*args) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sharded_database/model_with_connection.rb', line 26 def find_with_connection(*args) if args.last.is_a?(Hash) && connection_arg = args.last.delete(:connection) connection = case connection_arg when Symbol then send(connection_arg, *args) when Proc then connection_arg.call(*args) when Class then connection_arg end ModelWithConnection.borrow_connection(self, connection) { find_without_connection(*args) } else find_without_connection(*args) end end |