Her is an ORM (Object Relational Mapper) that maps REST resources to Ruby objects. It is designed to build applications that are powered by a RESTful API.
In your Gemfile, add:
First, you have to define which API your models will be bound to. For example, with Rails, you would create a new
config/initializers/her.rb file with this line:
Her::API.setup :base_uri => "https://api.example.com"
And then to add the ORM behavior to a class, you just have to include
Her::Model in it:
class User include Her::Model end
After that, using Her is very similar to many ActiveModel-like ORMs:
User.all # => Fetches "https://api.example.com/users" and return an array of User objects User.find(1) # => Fetches "https://api.example.com/users/1" and return a User object
class User include Her::Model has_many :comments end class Comment include Her::Model end user = User.find(1) user.comments # => [#<Comment id=1>, #<Comment id=2>]