Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
103 lines (64 sloc) 3.78 KB

Evoke Client

The Evoke client is a simple HTTParty utility for allowing your application to converse with an Evoke service.

Soon, there will be a global Evoke app that your app can talk to. For now, you should run your own server.


Essentially, the Evoke client acts like an ActiveRecord model. The basic methods are:

  • Evoke::Callback.find(guid)
  • Evoke::Callback.create_or_update(attributes_hash)
  • Evoke::Callback#update_attributes(hash_to_merge)
  • Evoke::Callback#save
  • Evoke::Callback#destroy

Typically, you would simply need to call create_or_update from wherever you are calling out to Evoke. Most of the apps we use Evoke client with make calls similar to the following:

class SomeObject
  def some_method
      "guid" => "some-kind-of-unique-string",
      "url" => "",
      "callback_at" => + 3600)

The Evoke client will raise an Evoke::RecordInvalid exception if the callback could not be created or updated for some reason. This is the same for an explicit call to save. The reason for the failure will be returned in the exception as the message.

If you wanted to explicitly do what create_or_update is doing for you in your code, you would likely write your code like so:

callback = Evoke::Callback.find("some-kind-of-unique-string")
if callback
  callback.update_attributes("callback_at" => + 3600)
  callback =
    "guid" => "some-kind-of-unique-string",
    "url" => "",
    "callback_at" => + 3600)

If you no longer need a callback, you can destroy it. Simply find the callback and then call its destroy method.

callback = Evoke::Callback.find("some-kind-of-unique-string")


To modify host and port, just set the following somewhere after you have required in (see following sections) the Evoke client:

Evoke.configure ""

If you're using a newer version Rails, you could set it in an initializer. However, you may not want to be adding callbacks to your production instance of Evoke when doing local development. It's probably better to explicitly configure Evoke in your development.rb and production.rb files.

Then, if you're using Rails, put this is your development.rb and production.rb files:

config.gem 'evoke_client', :src => ""

Otherwise, do the standard:

require 'evoke_client'


If using Rails, put this is your config/environment/test.rb:

config.gem 'evoke_client', :lib => 'evoke_client/mock', :src => ""

If not using Rails, put this in your test_helper.rb or whatever you call it:

require 'evoke_client/mock'

You need to make sure you have required in evoke_client/mock AFTER you have required evoke_client. Otherwise ... bad stuff.

Don't worry about calling Evoke.configure if you're requiring in the mock library. It's irrelevant. What is relevant, however, is mocking out the calls Evoke client will send to HTTParty. Evoke client has a solution, but I need to document it here and I'm not ready yet. Sorry.



If you haven't done so yet, you should add the GemCutter source to your list of gem sources:

gem sources -a

Then installing the Evoke client is as simple as:

gem install evoke_client


These should be automatically installed when you install evoke_client


MIT, baby! (see file named MIT-LICENSE)