Module: RubyApp::Mixins::RouteMixin
- Included in:
- Rack::Route
- Defined in:
- lib/ruby_app/mixins/route_mixin.rb
Constant Summary collapse
- GET =
'GET'
- POST =
'POST'
Instance Method Summary collapse
Instance Method Details
#do_route(method, path) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/ruby_app/mixins/route_mixin.rb', line 19 def do_route(method, path) self.routes.each do |route| if method == route[:method] and path =~ route[:pattern] return route[:block].call([method].concat($~.to_a)) end end end |
#route(method, pattern, &block) ⇒ Object
15 16 17 |
# File 'lib/ruby_app/mixins/route_mixin.rb', line 15 def route(method, pattern, &block) self.routes << { :method => method, :pattern => pattern, :block => block } end |
#routes ⇒ Object
27 28 29 |
# File 'lib/ruby_app/mixins/route_mixin.rb', line 27 def routes return @_routes ||= [] end |