Class: ArrayCache
- Inherits:
-
Object
- Object
- ArrayCache
- Defined in:
- lib/repositories/array_cache.rb
Overview
This is a FIFO array, a way to keep a limited queue. This is very useful for Percept Histories.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ ArrayCache
constructor
A new instance of ArrayCache.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ ArrayCache
Returns a new instance of ArrayCache.
10 11 12 13 14 |
# File 'lib/repositories/array_cache.rb', line 10 def initialize(opts={}) eviction_policy = SimpleArrayEviction.new(opts[:n]) @array = MonitoredArray.new @array.add_observer(eviction_policy) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
16 17 18 |
# File 'lib/repositories/array_cache.rb', line 16 def method_missing(sym, *args, &block) @array.send(sym, *args, &block) end |