Class: ResourceSubscriber::Middlewares::Resourceful
- Inherits:
-
Object
- Object
- ResourceSubscriber::Middlewares::Resourceful
- Defined in:
- lib/resource_subscriber/middlewares/resourceful.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Resourceful
constructor
A new instance of Resourceful.
Constructor Details
#initialize(app) ⇒ Resourceful
Returns a new instance of Resourceful.
4 5 6 |
# File 'lib/resource_subscriber/middlewares/resourceful.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/resource_subscriber/middlewares/resourceful.rb', line 8 def call(env) attributes = env["payload"]["resource"] model = env["payload"]["resource_type"].constantize env["resource"] = model.find(attributes["id"]) @app.call(env) end |