Sha256: 54eb547247e3d3add0cfdbb636985008dc3843513b5af6e1b4a305fd76e2e2e3

Contents?: true

Size: 518 Bytes

Versions: 2

Compression:

Stored size: 518 Bytes

Contents

module ConnectionManager
  module Relation
    # Specify connection class to used for query. For
    # example:
    #
    # users = User.using(MySlaveConnection).first
    def using(connection_class_name)
      @klass = ConnectionManager::Using::Proxy.new(@klass,connection_class_name)
      self
    end

    def slaves
      using(@klass.fetch_slave_connection)
    end

    def masters
      using(@klass.fetch_master_connection)
    end
  end
end
ActiveRecord::Relation.send(:include, ConnectionManager::Relation)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
connection_manager-2.0.0 lib/connection_manager/relation.rb
connection_manager-1.1.5 lib/connection_manager/relation.rb