Class: Evoke
- Inherits:
-
Object
show all
- Defined in:
- lib/evoke_client.rb
Defined Under Namespace
Classes: ConnectionRefused
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ Evoke
Returns a new instance of Evoke.
23
24
25
26
27
28
|
# File 'lib/evoke_client.rb', line 23
def initialize(params={})
@evoke = RestClient::Resource.new("http://#{Evoke.host_and_port}/callbacks")
@params = params
@params[:callback_at] = @params[:callback_at].utc if @params[:callback_at]
@params[:data] = @params[:data].to_query_string if @params[:data]
end
|
Instance Attribute Details
Returns the value of attribute headers.
21
22
23
|
# File 'lib/evoke_client.rb', line 21
def
@headers
end
|
#params ⇒ Object
Returns the value of attribute params.
21
22
23
|
# File 'lib/evoke_client.rb', line 21
def params
@params
end
|
Class Method Details
.create_or_update!(*args) ⇒ Object
17
18
19
|
# File 'lib/evoke_client.rb', line 17
def self.create_or_update!(*args)
Evoke.new(*args).save
end
|
.host ⇒ Object
7
|
# File 'lib/evoke_client.rb', line 7
def self.host; @host || 'evoke.thumblemonks.com'; end
|
.host=(host) ⇒ Object
8
|
# File 'lib/evoke_client.rb', line 8
def self.host=(host) @host = host; end
|
.host_and_port ⇒ Object
13
14
15
|
# File 'lib/evoke_client.rb', line 13
def self.host_and_port
[host, port].compact.join(':')
end
|
.port ⇒ Object
10
|
# File 'lib/evoke_client.rb', line 10
def self.port; @port; end
|
.port=(port) ⇒ Object
11
|
# File 'lib/evoke_client.rb', line 11
def self.port=(port) @port = port; end
|
Instance Method Details
#save ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/evoke_client.rb', line 30
def save
@evoke[params[:guid]].get
@evoke[params[:guid]].put(@params)
rescue RestClient::ResourceNotFound
@evoke.post(@params)
rescue Errno::ECONNREFUSED
raise ConnectionRefused, "Connection refused while connecting to #{Evoke.host_and_port}"
end
|