Module: Ephemeron::Store::AllowFetch

Defined in:
lib/ephemeron/store/allow_fetch.rb

Class Method Summary collapse

Class Method Details

.call(model) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/ephemeron/store/allow_fetch.rb', line 8

def call(model)
  last_events = Ephemeron::Logger::Finders
                .find_all_events_for(model, :fetch_allowed, :fetched)
                .last(2)
  cond1 = last_events[0] == Logger::Convert.call(model, :fetch_allowed)
  cond2 = last_events[1] == Logger::Convert.call(model, :fetched)
  cond1 && cond2
end