Class: Roart::Connection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf) ⇒ Connection

Returns a new instance of Connection.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/roart/connection.rb', line 16

def initialize(conf)
  if conf.is_a?(String)
    raise RoartError, "Loading Config File not yet implemented"
  elsif conf.class.name == Hash.name #TODO: Figure out why conf.is_a?(Hash) doesn't work
    @conf = conf
  end
  if Roart::check_keys(conf, Roart::Connections::RequiredConfig)
    @agent = @conf[:login]
    add_methods!
  else
    raise RoartError, "Configuration Error"
  end
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



13
14
15
# File 'lib/roart/connection.rb', line 13

def agent
  @agent
end

#confObject (readonly)

Returns the value of attribute conf.



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

def conf
  @conf
end

Instance Method Details

#authenticate(conf) ⇒ Object



30
31
32
33
34
35
# File 'lib/roart/connection.rb', line 30

def authenticate(conf)
  if Roart::check_keys(conf, Roart::Connections::RequiredToLogin)
    connection.authenticate(conf)
    self
  end
end

#get(uri) ⇒ Object



41
42
43
# File 'lib/roart/connection.rb', line 41

def get(uri)
  connection.get(uri)
end

#post(uri, payload) ⇒ Object



45
46
47
# File 'lib/roart/connection.rb', line 45

def post(uri, payload)
  connection.post(uri, payload)
end

#rest_pathObject



37
38
39
# File 'lib/roart/connection.rb', line 37

def rest_path
  self.server + '/REST/1.0/'
end