Class: ROM::Cache::Namespaced Private

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

Overview

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.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache, namespace) ⇒ 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.

API:

  • private



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

def initialize(cache, namespace)
  @cache = cache
  @namespace = namespace.to_sym
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.

API:

  • private



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.

API:

  • private



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

def namespace
  @namespace
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.

API:

  • private



27
28
29
# File 'lib/rom/cache.rb', line 27

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.

API:

  • private



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

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.

API:

  • private



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

def inspect
  %(#<#{self.class} size=#{size}>)
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.

API:

  • private



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

def size
  cache.size
end