Class: Pipeloader::Batch::FetcherState
- Inherits:
-
Object
- Object
- Pipeloader::Batch::FetcherState
- Defined in:
- lib/pipeloader/batch/fetcher_state.rb
Overview
Per-instance, per-relationship cache. The first access triggers the (batched) fetch; subsequent accesses return the cached slice.
Instance Attribute Summary collapse
-
#fetched ⇒ Object
readonly
Returns the value of attribute fetched.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #fetch(owner) ⇒ Object
-
#initialize(fetcher) ⇒ FetcherState
constructor
A new instance of FetcherState.
Constructor Details
#initialize(fetcher) ⇒ FetcherState
Returns a new instance of FetcherState.
10 11 12 13 14 |
# File 'lib/pipeloader/batch/fetcher_state.rb', line 10 def initialize(fetcher) @fetcher = fetcher @fetched = false @results = nil end |
Instance Attribute Details
#fetched ⇒ Object (readonly)
Returns the value of attribute fetched.
8 9 10 |
# File 'lib/pipeloader/batch/fetcher_state.rb', line 8 def fetched @fetched end |
#results ⇒ Object
Returns the value of attribute results.
8 9 10 |
# File 'lib/pipeloader/batch/fetcher_state.rb', line 8 def results @results end |
Instance Method Details
#fetch(owner) ⇒ Object
16 17 18 19 |
# File 'lib/pipeloader/batch/fetcher_state.rb', line 16 def fetch(owner) @fetcher.fetch(owner) unless @fetched @results end |