Module: Mize::Configure
- Included in:
- Mize
- Defined in:
- lib/mize/configure.rb
Overview
Configuration helpers mixed in / extended onto the top-level Mize object.
Provides the block-based Mize.configure DSL and the default_cache
accessor so users can swap the global cache backend.
Instance Attribute Summary collapse
-
#default_cache ⇒ Mize::CacheProtocol
The global default cache backend.
Instance Method Summary collapse
-
#cache(cache) ⇒ Mize::CacheProtocol
Set the default cache object to
cache. -
#configure { ... } ⇒ Object
Configure Mize by evaluating
blockin the context of theMizeobject.
Instance Attribute Details
#default_cache ⇒ Mize::CacheProtocol
The global default cache backend.
Every memoized object that has not been given an explicit cache
instantiates a fresh copy (via prototype / "dup") of this backend.
Reassign it to route all new memoized calls through a different store
(Redis, Memcached, ...).
14 15 16 |
# File 'lib/mize/configure.rb', line 14 def default_cache @default_cache end |
Instance Method Details
#cache(cache) ⇒ Mize::CacheProtocol
Set the default cache object to cache.
Intended for use inside a Mize.configure {} block.
22 23 24 |
# File 'lib/mize/configure.rb', line 22 def cache(cache) self.default_cache = cache end |
#configure { ... } ⇒ Object
Configure Mize by evaluating block in the context of the Mize object.
Inside the block, cache (and the default_cache accessor) are called
directly on Mize, so no receiver is required.
38 39 40 |
# File 'lib/mize/configure.rb', line 38 def configure(&block) instance_eval(&block) end |