Module: Mrcr::Cache::Methods

Defined in:
lib/mrcr/cache.rb

Overview

Instance methods

Instance Method Summary collapse

Instance Method Details

#fetch(key, default = nil) ⇒ Object

Delegates call to the class-level method

Parameters:

  • key (Object)

    Hashable object

  • default (Object) (defaults to: nil)

    Default value.

Returns:

  • (Object)

    return value or default



83
84
85
# File 'lib/mrcr/cache.rb', line 83

def fetch(key, default = nil)
  self.class.fetch(key, default)
end

#fetch_or_store(key) { ... } ⇒ Object

Delegates call to the class-level method

Parameters:

  • key (Object)

    Hashable object

Yields:

  • An arbitrary block

Returns:

  • (Object)

    block’s return value



73
74
75
# File 'lib/mrcr/cache.rb', line 73

def fetch_or_store(key, &block)
  self.class.fetch_or_store(key, &block)
end