Sha256: 5e1572ccff729126924dc24a356bca726cbbc2a22819c2eb286c45fe8e4f6478
Contents?: true
Size: 883 Bytes
Versions: 8
Compression:
Stored size: 883 Bytes
Contents
require 'routemaster/dirty/map' module Routemaster module Middleware # If an event payload was place in the environment # (`env['routemaster.payload']`) by a previous middleware, # mark each corresponding entity as dirty. # # All events are passed through. # # The dirty map is passed as `:map` to the constructor and must respond to # `#mark` (like `Routemaster::Dirty::Map`). class Dirty def initialize(app, options = {}) @app = app @map = options.fetch(:dirty_map) { Routemaster::Dirty::Map.new } end def call(env) env['routemaster.dirty'] = dirty = [] env.fetch('routemaster.payload', []).each do |event| next if event['type'] == 'noop' next unless @map.mark(event['url']) dirty << event['url'] end @app.call(env) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems