Class: Evoke
- Inherits:
-
Object
- Object
- Evoke
- Defined in:
- lib/evoke_client.rb
Defined Under Namespace
Classes: ConnectionRefused
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.create_or_update!(*args) ⇒ Object
Logic.
-
.host ⇒ Object
Configuration.
- .host=(host) ⇒ Object
- .host_and_port ⇒ Object
- .port ⇒ Object
- .port=(port) ⇒ Object
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Evoke
constructor
A new instance of Evoke.
- #save ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Evoke
Returns a new instance of Evoke.
27 28 29 30 31 32 |
# File 'lib/evoke_client.rb', line 27 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
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
25 26 27 |
# File 'lib/evoke_client.rb', line 25 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
25 26 27 |
# File 'lib/evoke_client.rb', line 25 def params @params end |
Class Method Details
.create_or_update!(*args) ⇒ Object
Logic
21 22 23 |
# File 'lib/evoke_client.rb', line 21 def self.create_or_update!(*args) Evoke.new(*args).save end |
.host ⇒ Object
Configuration
9 |
# File 'lib/evoke_client.rb', line 9 def self.host; @host || 'evoke.thumblemonks.com'; end |
.host=(host) ⇒ Object
10 |
# File 'lib/evoke_client.rb', line 10 def self.host=(host) @host = host; end |
.host_and_port ⇒ Object
15 16 17 |
# File 'lib/evoke_client.rb', line 15 def self.host_and_port [host, port].compact.join(':') end |
.port ⇒ Object
12 |
# File 'lib/evoke_client.rb', line 12 def self.port; @port; end |
.port=(port) ⇒ Object
13 |
# File 'lib/evoke_client.rb', line 13 def self.port=(port) @port = port; end |
Instance Method Details
#save ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/evoke_client.rb', line 34 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 |