Class: Ciclope::Ring
- Inherits:
-
Object
- Object
- Ciclope::Ring
- Defined in:
- lib/ciclope/ring.rb
Defined Under Namespace
Classes: NotEnoughConnections
Instance Attribute Summary collapse
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Ring
constructor
A new instance of Ring.
Constructor Details
#initialize(*args) ⇒ Ring
Returns a new instance of Ring.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ciclope/ring.rb', line 11 def initialize(*args) = args.pop if args.last.is_a? Hash ||= {} connections = Array(args).flatten.compact.uniq @hosts = [] connections.each do |c| config = Rails.configuration.database_configuration[c.to_s] next unless config && config['adapter'] == 'mysql' @hosts << Host.new(ActiveRecord::Base.mysql_connection(config)) end raise NotEnoughConnections if connections.size < 2 @hosts = @hosts.sort if [:sort_hosts] && @hosts.count > 2 end |
Instance Attribute Details
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
9 10 11 |
# File 'lib/ciclope/ring.rb', line 9 def hosts @hosts end |