Class: HammerCLI::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/hammer_cli/connection.rb

Class Method Summary collapse

Class Method Details

.create(name, conector_params = {}, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/hammer_cli/connection.rb', line 18

def self.create(name, conector_params={}, options={})
  unless connections[name]
    Logging.logger['Connection'].debug "Registered: #{name}"
    connector = options[:connector] || AbstractConnector

    connections[name] = connector.new(conector_params)
  end
  connections[name]
end

.drop(name) ⇒ Object



10
11
12
# File 'lib/hammer_cli/connection.rb', line 10

def self.drop(name)
  connections.delete(name)
end

.drop_allObject



14
15
16
# File 'lib/hammer_cli/connection.rb', line 14

def self.drop_all()
  connections.keys.each { |c| drop(c) }
end

.exist?(name) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/hammer_cli/connection.rb', line 28

def self.exist?(name)
  !get(name).nil?
end

.get(name) ⇒ Object



32
33
34
# File 'lib/hammer_cli/connection.rb', line 32

def self.get(name)
  connections[name]
end