Gem extends active resource to consume devise_hash_token_authenticatble services. Devise Hash Token Authenticatable is a Token based authentication strategy for the Devise.
Suppose I have an api at https://mypim.com/api/v1/contacts that exposes restful services using devise_hash_token_autheticatable. I have a user account with and id=57 and hash key of: 3c5abf29fafe6e528f88391f034f013gggg17b38acf49b9cc43f28f09d8101f2
First I create the following model to consume my service
#app/models/contact.rb
class Contact < ActiveResourceHashed::Base
self.site = 'https://mypim.com/api/v1/'
self.hash_id = 57
self.hash_key = '3c5abf29fafe6e528f88391f034f013gggg17b38acf49b9cc43f28f09d8101f2'
self.element_name = "contact"
def self.search(q = nil)
self.find(:all, {params:{q:"#{search_phrase}"}})
end
end
Then I can consume the service as I would using active resource. For example:
contact_8899 = Contact.find(8899)
contact_8899.id # 8899
contact_8899.full_name # John Smith
johns = Contact.search('John')
johns.first.full_name # John Smith
johns.last.full_name # Sally Smith
- service running devise_hash_token_authenticatable
- active_resource
Add this line to your application's Gemfile:
gem 'active_resource_hashed'
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Released under the MIT license
Copyright (c) 2012 Domain7