class Serf::Middleware::UuidTagger
Middleware
to add the uuid to the parcel hash if not already present.
Attributes
app[R]
uuidable[R]
Public Class Methods
new(app, *args)
click to toggle source
@param app the app
# File lib/serf/middleware/uuid_tagger.rb, line 19 def initialize(app, *args) opts = Optser.extract_options! args @app = app @uuidable = opts.get(:uuidable) { Serf::Util::Uuidable.new } end
Public Instance Methods
call(parcel)
click to toggle source
# File lib/serf/middleware/uuid_tagger.rb, line 25 def call(parcel) # Duplicate the parcel parcel = parcel.dup # Tag with a UUID unless it already has one parcel[:uuid] ||= uuidable.create_coded_uuid # Pass on the given parcel with the uuid app.call parcel end