class SimpleJSONAPIDeserializer::Resource::Cache

Attributes

cached_resources[R]

Public Class Methods

new() click to toggle source
# File lib/simple_jsonapi_deserializer/resource/cache.rb, line 4
def initialize
  @cached_resources = {}
end

Public Instance Methods

cache(id, type, deserialized_resource) click to toggle source
# File lib/simple_jsonapi_deserializer/resource/cache.rb, line 8
def cache(id, type, deserialized_resource)
  cached_resources[type] ||= {}
  cached_resources[type][id] = deserialized_resource
end
cached?(id, type) click to toggle source
# File lib/simple_jsonapi_deserializer/resource/cache.rb, line 13
def cached?(id, type)
  cached_resource(id, type)
end
find(id, type) click to toggle source
# File lib/simple_jsonapi_deserializer/resource/cache.rb, line 17
def find(id, type)
  cached_resources.dig(type, id)
end