Class: Roart::Connection
- Inherits:
-
Object
- Object
- Roart::Connection
- Defined in:
- lib/roart/connection.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
Instance Method Summary collapse
- #authenticate(conf) ⇒ Object
- #get(uri) ⇒ Object
-
#initialize(conf) ⇒ Connection
constructor
A new instance of Connection.
- #post(uri, payload) ⇒ Object
- #rest_path ⇒ Object
Constructor Details
#initialize(conf) ⇒ Connection
Returns a new instance of Connection.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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! @connection = ConnectionAdapter.new(@conf) else raise RoartError, "Configuration Error" end end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
13 14 15 |
# File 'lib/roart/connection.rb', line 13 def agent @agent end |
#conf ⇒ Object (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
31 32 33 34 35 36 |
# File 'lib/roart/connection.rb', line 31 def authenticate(conf) if Roart::check_keys(conf, Roart::Connections::RequiredToLogin) @connection.authenticate(conf) self end end |
#get(uri) ⇒ Object
42 43 44 |
# File 'lib/roart/connection.rb', line 42 def get(uri) @connection.get(uri) end |
#post(uri, payload) ⇒ Object
46 47 48 |
# File 'lib/roart/connection.rb', line 46 def post(uri, payload) @connection.post(uri, payload) end |
#rest_path ⇒ Object
38 39 40 |
# File 'lib/roart/connection.rb', line 38 def rest_path self.server + '/REST/1.0/' end |