Module: Roar::JSON::JSONAPI

Defined in:
lib/roar/json/json_api.rb,
lib/roar/json/json_api/meta.rb,
lib/roar/json/json_api/options.rb,
lib/roar/json/json_api/version.rb,
lib/roar/json/json_api/defaults.rb,
lib/roar/json/json_api/document.rb,
lib/roar/json/json_api/declarative.rb,
lib/roar/json/json_api/member_name.rb,
lib/roar/json/json_api/for_collection.rb,
lib/roar/json/json_api/single_resource.rb,
lib/roar/json/json_api/resource_collection.rb

Defined Under Namespace

Modules: Declarative, Defaults, Document, ForCollection, Fragment, Meta, Mixin, Options, Renderer, ResourceCollection, SingleResource Classes: MemberName, Resource

Constant Summary collapse

VERSION =
'0.0.3'.freeze

Class Method Summary collapse

Class Method Details

.resource(type, options = {}) ⇒ Object

Include to define a JSON API Resource and make API methods available to your Roar::Decorator.

Examples:

Basic Usage

class SongsRepresenter < Roar::Decorator
  include Roar::JSON::JSONAPI.resource :songs
end

Custom ID key

class SongsRepresenter < Roar::Decorator
  include Roar::JSON::JSONAPI.resource :songs, id_key: :song_id
end

Parameters:

  • type (Symbol, String)

    type name of this resource.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id_key (Symbol)

    custom ID key for this resource.

See Also:



70
71
72
# File 'lib/roar/json/json_api.rb', line 70

def self.resource(type, options = {})
  Resource.new(type, options)
end