Sha256: ebd43955187937e646e92f2a43b6d879ba96ee66b5ed05a6d2c7f187c54d9872

Contents?: true

Size: 625 Bytes

Versions: 5

Compression:

Stored size: 625 Bytes

Contents

# frozen_string_literal: true
class Cognito
  class Client
    class Document
      include Anima.new(:data, :included), Adamantium

      def initialize(data:, included: [])
        super
      end

      def resolve(resource_object)
        lookup.fetch(resource_object).first
      end

      def include(resource)
        with(included: included + resource.included)
      end

      private

      def lookup
        resources.group_by(&ResourceIdentifier)
      end
      memoize(:lookup)

      def resources
        included + [data]
      end
      memoize :resources
    end # Document
  end # Client
end # Cognito

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cognito-client-0.5.4 lib/cognito/client/document.rb
cognito-client-0.5.3 lib/cognito/client/document.rb
cognito-client-0.5.2 lib/cognito/client/document.rb
cognito-client-0.5.1 lib/cognito/client/document.rb
cognito-client-0.5.0 lib/cognito/client/document.rb