Module: Roar::JSON::JSONAPI::Mixin
- Defined in:
- lib/roar/json/json_api.rb
Overview
Include to make API methods available to your Roar::Decorator
.
Unlike Resource, you must define a type
(by calling
Declarative#type) and id
property separately.
Class Method Summary collapse
-
.included(base) ⇒ undefined
private
Hook called when module is included.
Class Method Details
.included(base) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Hook called when module is included
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/roar/json/json_api.rb', line 99 def self.included(base) base.class_eval do feature Roar::JSON feature Roar::Hypermedia feature JSONAPI::Defaults, JSONAPI::Meta extend JSONAPI::Declarative extend JSONAPI::ForCollection include JSONAPI::Document include JSONAPI::SingleResource self.representation_wrap = :data nested :relationships do end nested :included do def to_hash(*) super.flat_map { |_, resource| resource } end end end end |