Class: CacheMethod::Generation
- Inherits:
-
Object
- Object
- CacheMethod::Generation
- Defined in:
- lib/cache_method/generation.rb
Overview
:nodoc: all
Instance Attribute Summary collapse
-
#method_id ⇒ Object
readonly
Returns the value of attribute method_id.
-
#method_signature ⇒ Object
readonly
Returns the value of attribute method_signature.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(obj, method_id) ⇒ Generation
constructor
A new instance of Generation.
- #mark_passing ⇒ Object
Constructor Details
#initialize(obj, method_id) ⇒ Generation
Returns a new instance of Generation.
3 4 5 6 7 8 |
# File 'lib/cache_method/generation.rb', line 3 def initialize(obj, method_id) @obj = obj @method_id = method_id @method_signature = CacheMethod.method_signature obj, method_id @fetch_mutex = ::Mutex.new end |
Instance Attribute Details
#method_id ⇒ Object (readonly)
Returns the value of attribute method_id.
11 12 13 |
# File 'lib/cache_method/generation.rb', line 11 def method_id @method_id end |
#method_signature ⇒ Object (readonly)
Returns the value of attribute method_signature.
12 13 14 |
# File 'lib/cache_method/generation.rb', line 12 def method_signature @method_signature end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
10 11 12 |
# File 'lib/cache_method/generation.rb', line 10 def obj @obj end |
Instance Method Details
#fetch ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/cache_method/generation.rb', line 14 def fetch if existing = get existing else @fetch_mutex.synchronize do get || set end end end |
#mark_passing ⇒ Object
24 25 26 |
# File 'lib/cache_method/generation.rb', line 24 def mark_passing CacheMethod.config.storage.delete cache_key end |