Class: RosettaQueue::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/rosetta_queue/adapter.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.host=(value) ⇒ Object (writeonly)

Sets the attribute host

Parameters:

  • value

    the value to set the attribute host to.



7
8
9
# File 'lib/rosetta_queue/adapter.rb', line 7

def host=(value)
  @host = value
end

.password=(value) ⇒ Object (writeonly)

Sets the attribute password

Parameters:

  • value

    the value to set the attribute password to.



7
8
9
# File 'lib/rosetta_queue/adapter.rb', line 7

def password=(value)
  @password = value
end

.port=(value) ⇒ Object (writeonly)

Sets the attribute port

Parameters:

  • value

    the value to set the attribute port to.



7
8
9
# File 'lib/rosetta_queue/adapter.rb', line 7

def port=(value)
  @port = value
end

.user=(value) ⇒ Object (writeonly)

Sets the attribute user

Parameters:

  • value

    the value to set the attribute user to.



7
8
9
# File 'lib/rosetta_queue/adapter.rb', line 7

def user=(value)
  @user = value
end

Class Method Details

.define {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



9
10
11
# File 'lib/rosetta_queue/adapter.rb', line 9

def define
  yield self
end

.instanceObject

Raises:



26
27
28
29
# File 'lib/rosetta_queue/adapter.rb', line 26

def instance
  raise AdapterException, "Adapter type was never defined!" unless @adapter_class
  @adapter_class.new(@user, @password, @host, @port)
end

.resetObject



13
14
15
# File 'lib/rosetta_queue/adapter.rb', line 13

def reset
  @user, @password, @host, @port, @adapter_class = nil, nil, nil, nil, nil
end

.type=(adapter_prefix) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rosetta_queue/adapter.rb', line 17

def type=(adapter_prefix)
  begin
    require "rosetta_queue/adapters/#{adapter_prefix}"
  rescue LoadError
    raise AdapterException, "Adapter type '#{adapter_prefix}' does not match existing adapters!"
  end
  @adapter_class = RosettaQueue::Gateway.const_get("#{adapter_prefix.to_s.classify}Adapter")
end