Arke

Arke is a RESTful API client library designed specifically for utilizing distributed services in a service oriented environment.

Compatibility

Arke is developed against MRI 2.1.0 and tested against MRI 1.9.3, 2.0.0, and 2.1.0.

Basic Usage

Arke's model format is similar to that of Mongoid's:

class User
    include Arke::Resource::model

    host 'http://localhost:3000'

    field :email, type: String

end

Advanced Usage

Fields

Fields are required to access data returned from the service resource. If a field is not defined it will not be accessible from the model. This allows the fields to be serialized as the developer requires, and allows them to be fully integrated into Rails form_for. The field type defaults to String.

Hosts

Arke makes it easy to access multiple different hosts. The host directive defines the host the request will be sent to.

Endpoints

The endpoint is the location on the host for the specified resource. By default the endpoint is the tablelized name of the model. So in the case of a class named User the endpoint would be /users

Endpoints can be redefined as necessary by passing the endpoint directive:

class User
    include Arke::Resource::model

    host     'http://localhost:3000'
    endpoint 'members'

    field :email, type: String

end

Deserializers

By default Arke assumes data will be coming back as JSON. You can define a custom deserialization method using the deserializer directive:

class User
    include Arke::Resource::model

    host 'http://localhost:3000'

    deserializer { |response| MessagePack.unpack(response.body) }

    field :email, type: String

end

URL Templates

Arke uses Addressable for url templating.