class Rnow::Connection
Attributes
adapter[RW]
adapter_block[RW]
connection[RW]
host[RW]
logger[RW]
password[RW]
ssl_opts[RW]
username[RW]
Public Class Methods
new(opts={})
click to toggle source
# File lib/rnow/connection.rb, line 55 def initialize(opts={}) self.username = opts[:username] self.password = opts[:password] self.host = opts[:host] self.logger = opts[:logger] self.ssl_opts = opts[:ssl_opts] end
Public Instance Methods
delete(href)
click to toggle source
# File lib/rnow/connection.rb, line 49 def delete(href) wrap do connection.delete(href) end end
get(href, params={})
click to toggle source
# File lib/rnow/connection.rb, line 25 def get(href, params={}) wrap do connection.get(href, params) end end
host=(new_host)
click to toggle source
The host variable is expected to be a protocol with a host name. If the host has no protocol, https:// is added before it.
# File lib/rnow/connection.rb, line 77 def host=(new_host) unless new_host =~ /^http(s)?:\/\// new_host = "https://#{new_host}" end @host = new_host end
inspect()
click to toggle source
Don’t display the username/password in logging, etc.
# File lib/rnow/connection.rb, line 91 def inspect "#<#{self.class}:#{object_id} @host=\"#{@host}\">" end
post(href, body)
click to toggle source
# File lib/rnow/connection.rb, line 31 def post(href, body) wrap do connection.post do |req| req.url href req.body = body.to_json end end end
put(href, body)
click to toggle source
# File lib/rnow/connection.rb, line 40 def put(href, body) wrap do connection.put do |req| req.url href req.body = body.to_json end end end
Private Instance Methods
wrap() { || ... }
click to toggle source
# File lib/rnow/connection.rb, line 97 def wrap yield.tap do |response| unless response.status < 300 raise Rnow::Error.new("Error: #{response.status} #{response.body}") end