Class: Taskinator::Persistence::LazyLoader
- Inherits:
-
Delegator
- Object
- Delegator
- Taskinator::Persistence::LazyLoader
- Defined in:
- lib/taskinator/persistence.rb
Overview
lazily loads the object specified by the type and uuid
Instance Method Summary collapse
- #__getobj__ ⇒ Object
-
#initialize(type, uuid, instance_cache = {}) ⇒ LazyLoader
constructor
NOTE: the instance cached is passed from the first deserializer onto the next one, to prevent needing to keep loading the same objects again.
Constructor Details
#initialize(type, uuid, instance_cache = {}) ⇒ LazyLoader
NOTE: the instance cached is passed from the first deserializer onto the next one, to prevent needing to keep loading the same objects again.
E.g. this is useful for tasks which refer to their parent processes
625 626 627 628 629 |
# File 'lib/taskinator/persistence.rb', line 625 def initialize(type, uuid, instance_cache={}) @type = type @uuid = uuid @instance_cache = instance_cache end |
Instance Method Details
#__getobj__ ⇒ Object
631 632 633 634 635 |
# File 'lib/taskinator/persistence.rb', line 631 def __getobj__ # only fetch the object as needed # and memoize for subsequent calls @instance ||= @type.fetch(@uuid, @instance_cache) end |