Class: ROM::Cache::Namespaced Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/cache.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache, namespace, parent:) ⇒ Namespaced

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Namespaced.



24
25
26
27
28
# File 'lib/rom/cache.rb', line 24

def initialize(cache, namespace, parent:)
  @cache = cache
  @namespace = namespace
  @parent = parent
end

Instance Attribute Details

#cacheObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
# File 'lib/rom/cache.rb', line 15

def cache
  @cache
end

#namespaceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
# File 'lib/rom/cache.rb', line 18

def namespace
  @namespace
end

#parentObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/rom/cache.rb', line 21

def parent
  @parent
end

Instance Method Details

#[](key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/rom/cache.rb', line 36

def [](key)
  cache[[namespace, key].hash]
end

#fetch_or_store(*args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/rom/cache.rb', line 41

def fetch_or_store(*args, &block)
  cache.fetch_or_store([namespace, args.hash].hash, &block)
end

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
# File 'lib/rom/cache.rb', line 51

def inspect
  %(#<#{self.class} size=#{size}>)
end

#namespaced(namespace) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/rom/cache.rb', line 31

def namespaced(namespace)
  parent.namespaced(namespace)
end

#sizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/rom/cache.rb', line 46

def size
  cache.size
end