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



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

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



13
14
15
# File 'lib/rom/cache.rb', line 13

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



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

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



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

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



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

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



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

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



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

def size
  cache.size
end