class Serf::Middleware::ParcelMasher
Middleware
to coerce the parcel to Hashie::Mash.
Attributes
app[R]
masher_class[R]
Public Class Methods
new(app, *args)
click to toggle source
@param app the app
# File lib/serf/middleware/parcel_masher.rb, line 17 def initialize(app, *args) opts = Optser.extract_options! args @app = app @masher_class = opts.get :masher_class, Hashie::Mash end
Public Instance Methods
call(parcel)
click to toggle source
Coerces the parcel into a Hashie::Mash, makes sure that the message field is set, and then passes it along the chain.
# File lib/serf/middleware/parcel_masher.rb, line 26 def call(parcel) mashed_parcel = masher_class.new parcel mashed_parcel[:message] ||= {} app.call mashed_parcel end