Sha256: 4ccc90115918997ba377e80ce62a8f7e5672f5c3b6ad0b25e3c8cf349fd56079

Contents?: true

Size: 961 Bytes

Versions: 10

Compression:

Stored size: 961 Bytes

Contents

module JSONAPIonify::Api
  module Resource::Defaults::ResponseContexts
    extend ActiveSupport::Concern

    included do
      context(:invalidate_cache?, readonly: true, persisted: true) do |includes:|
        includes.present?
      end

      # Response Objects
      context(:links, readonly: true, persisted: true) do |response_object:|
        response_object[:links]
      end

      context(:meta, readonly: true, persisted: true) do |response_object:|
        JSONAPIonify::Structure::Helpers::MetaDelegate.new response_object
      end

      context(:response_object, readonly: true, persisted: true) do |request:|
        JSONAPIonify.parse(links: { self: request.url })
      end

      context(:response_collection, readonly: true) do |collection:, nested_request: false, paginated_collection: nil, sorted_collection: nil|
        nested_request ? collection : paginated_collection || sorted_collection || collection
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jsonapionify-0.12.10 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.9 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.8 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.7 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.5 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.4 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.3 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.2 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.1 lib/jsonapionify/api/resource/defaults/response_contexts.rb
jsonapionify-0.12.0 lib/jsonapionify/api/resource/defaults/response_contexts.rb