Sha256: 8d291bb28fee3e3b3affcb8f7f545543f8df428ec40233464a775a92c8906444
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
# encoding: utf-8 module AMQP class Failover class Config < ::Hash attr_accessor :last_fail def initialize(hash = {}, last_fail_date = nil) self.replace(symbolize_keys(defaults.merge(hash))) self.last_fail = last_fail_date if last_fail_date end def defaults AMQP.settings end def symbolize_keys(hash = {}) hash.inject({}) do |result, (key, value)| result[key.is_a?(String) ? key.to_sym : key] = value result end end # order by latest fail, potentially useful if random config selection is used def <=>(other) if self.respond_to?(:last_fail) && other.respond_to?(:last_fail) if self.last_fail.nil? && other.last_fail.nil? return 0 elsif self.last_fail.nil? && !other.last_fail.nil? return 1 elsif !self.last_fail.nil? && other.last_fail.nil? return -1 end return other.last_fail <=> self.last_fail end return 0 end end # Config end # Failover end # AMQP
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
amqp-failover-0.0.2 | lib/amqp/failover/config.rb |
amqp-failover-0.0.1 | lib/amqp/failover/config.rb |