class Roar::JSON::JSONAPI::Resource
Include to define a JSON
API Resource
and make API methods available to your `Roar::Decorator`.
@api public
Public Class Methods
new(type, options = {})
click to toggle source
@param [Symbol, String] type type name of this resource. @option options [Symbol] :id_key custom ID key for this resource.
# File lib/roar/json/json_api.rb, line 27 def initialize(type, options = {}) @type = type @id_key = options.fetch(:id_key, :id) end
Private Instance Methods
included(base)
click to toggle source
Hook called when module is included
@param [Class,Module] base
the module or class including JSONAPI
@return [undefined]
@api private @see www.ruby-doc.org/core/Module.html#method-i-included
# File lib/roar/json/json_api.rb, line 43 def included(base) base.send(:include, JSONAPI::Mixin) base.type(@type) base.property(@id_key, as: :id, render_filter: ->(input, _opts) { input.to_s }) end