Class: Tom::Merger
- Inherits:
-
Object
- Object
- Tom::Merger
- Defined in:
- lib/merger.rb
Overview
Please see the README for examples on how to use this.
Class Method Summary collapse
-
.register_route(*args) ⇒ Object
Registers a route with the request dispatcher so that this classes subclass gets called when a request is made.
Instance Method Summary collapse
-
#merge(env, responses) ⇒ Array
When the request dispatcher made all the requests, it will call the merge method of the subclass with the responses as a hash in the form.
Class Method Details
.register_route(*args) ⇒ Object
Registers a route with the request dispatcher so that this classes subclass gets called when a request is made. One that matches the route.
The route can be a string, but it becomes a regular expression in here. When matching in order to find a merger for a request, the first one matching wins.
21 22 23 24 25 |
# File 'lib/merger.rb', line 21 def self.register_route(*args) route = args[0] methods = args[1..-1] Tom::Routes.register(route: /#{route}/, merger: self, methods: methods) end |
Instance Method Details
#merge(env, responses) ⇒ Array
When the request dispatcher made all the requests, it will call the merge method of the subclass with the responses as a hash in the form
38 39 40 |
# File 'lib/merger.rb', line 38 def merge(env, responses) raise "Subclass, implement #merge(env, responses)!" end |