Class: Pipeloader::Batch::FetcherState

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#fetchedObject (readonly)

Returns the value of attribute fetched.



8
9
10
# File 'lib/pipeloader/batch/fetcher_state.rb', line 8

def fetched
  @fetched
end

#resultsObject

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