Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Middleware classes can now define an `on_install` block to be called when an instance of it is created and added to the middleware stack of an agency. The callback will receive the agency as the only argument, and will be executed in the context of the Middleware class (not the instance. This is not set in stone, comments are welcome). Since #20 was opened, the `Schemable` module was implemented, changing the way attributes are added to objects. Because of this, and because of slightly different opinions on implementation, the actual code to achieve the same result as the example given in the issue (adding a `neighborhood` attribute to `Shark::Vehicle`) would simply be ``` class NeighborhoodMiddleware < Shark::Middleware on_install do |agency| Shark::Vehicle.attribute :neighborhood, type: String, nilable: true end end ```
- Loading branch information