Class: Simple::Sharding::ConnectionHandler::ConnectionPoolOwner

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

Overview

Connection pool need a class to own each connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ConnectionPoolOwner

Returns a new instance of ConnectionPoolOwner.



55
56
57
# File 'lib/simple/sharding/connection_handler.rb', line 55

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



53
54
55
# File 'lib/simple/sharding/connection_handler.rb', line 53

def name
  @name
end

Instance Method Details

#superclassObject

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

Raises:

  • (Exception)


60
61
62
# File 'lib/simple/sharding/connection_handler.rb', line 60

def superclass
  raise Exception, "ConnectionPool could not be retrieved for #{self}. "
end

#to_sObject

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



65
66
67
# File 'lib/simple/sharding/connection_handler.rb', line 65

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