Class: Contentful::ContentTypeCache

Inherits:
Object
  • Object
show all
Defined in:
lib/contentful/content_type_cache.rb

Overview

Cache for Content Types

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cacheObject (readonly)

Returns the value of attribute cache.



7
8
9
# File 'lib/contentful/content_type_cache.rb', line 7

def cache
  @cache
end

Class Method Details

.cache_get(space_id, content_type_id) ⇒ Object

Gets a Content Type from the Cache



16
17
18
# File 'lib/contentful/content_type_cache.rb', line 16

def self.cache_get(space_id, content_type_id)
  @cache.fetch(space_id, {}).fetch(content_type_id.to_sym, nil)
end

.cache_set(space_id, content_type_id, klass) ⇒ Object

Sets a Content Type in the Cache



21
22
23
24
# File 'lib/contentful/content_type_cache.rb', line 21

def self.cache_set(space_id, content_type_id, klass)
  @cache[space_id] ||= {}
  @cache[space_id][content_type_id.to_sym] = klass
end

.clear!Object

Clears the Content Type Cache



11
12
13
# File 'lib/contentful/content_type_cache.rb', line 11

def self.clear!
  @cache = {}
end