Sha256: 148306c98c19da8f025647c6bea6833b0f6b6d3bcb93eda8ab3739525a7a9368
Contents?: true
Size: 1.52 KB
Versions: 3
Compression:
Stored size: 1.52 KB
Contents
module Roar module JSON module JSONAPI # Meta information API for JSON API Representers. # # @api public module Meta # Hook called when module is included # # @param [Class,Module] base # the module or class including JSONAPI # # @return [undefined] # # @api private # @see http://www.ruby-doc.org/core/Module.html#method-i-included def self.included(base) base.extend ClassMethods end # Class level interface module ClassMethods # Define meta information. # # @example # meta do # property :copyright # collection :reviewers # end # # @param [#call] block # # @see http://jsonapi.org/format/#document-meta # @api public def meta(&block) representable_attrs[:meta_representer] ||= nested_builder.( _base: default_nested_class, _features: [Roar::JSON, JSONAPI::Defaults], _block: Proc.new ) representable_attrs[:meta_representer].instance_exec(&block) end end private def render_meta(options) representer = representable_attrs[:meta_representer] meta = representer ? representer.new(represented).to_hash : {} meta.merge!(options[:meta]) if options[:meta] meta end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
roar-jsonapi-0.0.3 | lib/roar/json/json_api/meta.rb |
roar-jsonapi-0.0.2 | lib/roar/json/json_api/meta.rb |
roar-jsonapi-0.0.1 | lib/roar/json/json_api/meta.rb |