<img src=“https://badge.fury.io/rb/logical_model.png” alt=“Gem Version” /> <img src=“https://travis-ci.org/dwaynemac/logical_model.png” /> <img src=“https://codeclimate.com/github/dwaynemac/logical_model.png” />

logical_model

LogicalModel allows to use a RESTfull resources as models.

It was written following this tutorial: www.slideshare.net/ihower/serviceoriented-design-and-implement-with-rails3

Assumptions

OUTDATED – some of this assumpitions are now configurable. Will update this readme as soon as possible.

LogicalModel makes some assumptions about the service you’ll be consuming

Usage

In your Gemfile:

gem "logical_model"

In a model file:

class RemoteResource < LogicalModel

  set_resource_host "remote.server"
  set_resource_path "/api/remote/path"
  # equivalent: set_resource_url "remote.server", "/api/remote/path"

  # optional
  set_api_key(:token, 'asdfasdf') # will add token=asdfasdf to all requests.

  attribute :id
  attribute :attribute_a
  attribute :attribute_b

  validates_presence_of :id
end

Testing

To run spec:

bundle exec rake

Contributing to logical_model

Copyright © 2011,2012,2013 Dwayne Macgowan. See LICENSE.txt for further details.

TODO