Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 37 lines (24 sloc) 0.993 kb
871ef96 @remiprev Add README
authored
1 # Her
2
3 [![Build Status](https://secure.travis-ci.org/remiprev/her.png)](http://travis-ci.org/remiprev/her)
4
5 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.
6
7 ## Installation
8
9 In your Gemfile, add:
10
11 gem "her"
12
13 ## Usage
14
15 To add the ORM to a class, you just have to include `Her::Model` in it and define which API you want it to be bound to. For example, with Rails, you would define a `config/initializers/her.rb` file with this:
16
17 ```ruby
18 $my_api = Her::API.new
19 $my_api.setup :base_uri => "https://api.example.com"
20 ```
21
22 And then, for each of your models:
23
24 ```ruby
25 class User
26 include Her::Model
27 uses_api $my_api
28 end
29 ```
30
31 After that, using Her is very similar to many ActiveModel-like ORMs:
32
33 ```ruby
34 User.all # => Fetches "https://api.example.com/users" and return an array of User objects
35 User.find(1) # => Fetches "https://api.example.com/users/1" and return a User object
36 ```
Something went wrong with that request. Please try again.