Sha256: c7c5a0c08c291f6b9c7bf76d2ffa27d5211f4ec753ca6fee3c2c4d01e1d8fd3e

Contents?: true

Size: 590 Bytes

Versions: 43

Compression:

Stored size: 590 Bytes

Contents

module Contentful
  # Cache for Content Types
  class ContentTypeCache
    @cache = {}

    class << self
      attr_reader :cache
    end

    # Clears the Content Type Cache
    def self.clear!
      @cache = {}
    end

    # Gets a Content Type from the Cache
    def self.cache_get(space_id, content_type_id)
      @cache.fetch(space_id, {}).fetch(content_type_id.to_sym, nil)
    end

    # Sets a Content Type in the Cache
    def self.cache_set(space_id, content_type_id, klass)
      @cache[space_id] ||= {}
      @cache[space_id][content_type_id.to_sym] = klass
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
contentful-2.0.2 lib/contentful/content_type_cache.rb
contentful-2.0.1 lib/contentful/content_type_cache.rb
contentful-2.0.0 lib/contentful/content_type_cache.rb