Class: Merb::Router::CachedProc
- Defined in:
- lib/merb-core/dispatch/router/cached_proc.rb
Overview
Cache procs for future reference in eval statement :api: private
Constant Summary collapse
- @@index =
0
- @@list =
[]
Instance Attribute Summary collapse
-
#cache ⇒ Object
:api: private.
-
#index ⇒ Object
:api: private.
Class Method Summary collapse
-
.[](index) ⇒ Object
Parameters index<Fixnum>:: The index of the cached code to retrieve.
-
.[]=(index, code) ⇒ Object
Sets the cached code for a specific index.
-
.register(cached_code) ⇒ Object
Parameters cached_code<CachedProc>:: The cached code to register.
Instance Method Summary collapse
-
#initialize(cache) ⇒ CachedProc
constructor
Parameters cache<Proc>:: The block of code to cache.
-
#to_s ⇒ Object
Returns String:: The CachedProc object in a format embeddable within a string.
Constructor Details
#initialize(cache) ⇒ CachedProc
Parameters
- cache<Proc>
-
The block of code to cache.
:api: private
17 18 19 |
# File 'lib/merb-core/dispatch/router/cached_proc.rb', line 17 def initialize(cache) @cache, @index = cache, CachedProc.register(self) end |
Instance Attribute Details
#cache ⇒ Object
:api: private
11 12 13 |
# File 'lib/merb-core/dispatch/router/cached_proc.rb', line 11 def cache @cache end |
#index ⇒ Object
:api: private
11 12 13 |
# File 'lib/merb-core/dispatch/router/cached_proc.rb', line 11 def index @index end |
Class Method Details
.[](index) ⇒ Object
Parameters
- index<Fixnum>
-
The index of the cached code to retrieve.
Returns
- CachedProc
-
The cached code at index.
:api: private
60 |
# File 'lib/merb-core/dispatch/router/cached_proc.rb', line 60 def [](index) @@list[index] end |
.[]=(index, code) ⇒ Object
Sets the cached code for a specific index.
Parameters
- index<Fixnum>
-
The index of the cached code to set.
- code<CachedProc>
-
The cached code to set.
:api: private
51 |
# File 'lib/merb-core/dispatch/router/cached_proc.rb', line 51 def []=(index, code) @@list[index] = code end |
.register(cached_code) ⇒ Object
Parameters
- cached_code<CachedProc>
-
The cached code to register.
Returns
- Fixnum
-
The index of the newly registered CachedProc.
:api: private
38 39 40 41 42 |
# File 'lib/merb-core/dispatch/router/cached_proc.rb', line 38 def register(cached_code) CachedProc[@@index] = cached_code @@index += 1 @@index - 1 end |
Instance Method Details
#to_s ⇒ Object
Returns
- String
-
The CachedProc object in a format embeddable within a string.
:api: private
25 26 27 |
# File 'lib/merb-core/dispatch/router/cached_proc.rb', line 25 def to_s "CachedProc[#{@index}].cache" end |