Sha256: e423bb3f5783959f85332f863148303d7c000d2668992bca2d10d843125156ba

Contents?: true

Size: 843 Bytes

Versions: 5

Compression:

Stored size: 843 Bytes

Contents

module ConnectionManager
  module AbstractAdapterHelper
    def config
      @config
    end
    
    def using_em_adapter?
      (config[:adapter].match(/^em\_/) && defined?(EM) && EM::reactor_running?)
    end
    
    def readonly?
      (config[:readonly] == true)
    end 
    
    def replicated?
      (!slave_keys.blank? || !master_keys.blank?)
    end
   
    def database_name
      config[:database]
    end
   
    def replication_keys(type=:slaves)
      return slave_keys if type == :slaves
      master_keys
    end
    
    def slave_keys
      slave_keys = []
      slave_keys = config[:slaves].collect{|r| r.to_sym} if config[:slaves]
      slave_keys  
    end
    
    def master_keys
      master_keys = []
      master_keys = config[:masters].collect{|r| r.to_sym} if config[:masters]
      master_keys
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
connection_manager-0.3.4 lib/connection_manager/helpers/abstract_adapter_helper.rb
connection_manager-0.3.3 lib/connection_manager/helpers/abstract_adapter_helper.rb
connection_manager-0.3.2 lib/connection_manager/helpers/abstract_adapter_helper.rb
connection_manager-0.3.1 lib/connection_manager/helpers/abstract_adapter_helper.rb
connection_manager-0.3.0 lib/connection_manager/helpers/abstract_adapter_helper.rb