Class: Rails::Sharding::ConnectionHandler::ConnectionPoolOwner

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/sharding/connection_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ConnectionPoolOwner

Returns a new instance of ConnectionPoolOwner.



89
90
91
# File 'lib/rails/sharding/connection_handler.rb', line 89

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



87
88
89
# File 'lib/rails/sharding/connection_handler.rb', line 87

def name
  @name
end

Instance Method Details

#superclassObject

Safeguard in case pool cannot be retrieved for owner. This makes the error clear



94
95
96
# File 'lib/rails/sharding/connection_handler.rb', line 94

def superclass
  raise Errors::ConnectionPoolRetrievalError, "ConnectionPool could not be retrieved for #{self}. See https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#607"
end

#to_sObject

in case owner ends up printed by rails in an error message when retrieving connection



99
100
101
# File 'lib/rails/sharding/connection_handler.rb', line 99

def to_s
  "ConnectionPoolOwner with name #{self.name}"
end