Module: Jeanine::Routing::DSL
Constant Summary collapse
- RouteError =
Class.new(StandardError)
Instance Method Summary collapse
- #delete(path = nil, options = {}, &block) ⇒ Object
- #get(path = nil, options = {}, &block) ⇒ Object
- #head(path = nil, options = {}, &block) ⇒ Object
- #match(path = nil, options = {}, &block) ⇒ Object
- #options(path = nil, options = {}, &block) ⇒ Object
- #patch(path = nil, options = {}, &block) ⇒ Object
- #path(pathname, options = {}, &block) ⇒ Object
- #post(path = nil, options = {}, &block) ⇒ Object
- #put(path = nil, options = {}, &block) ⇒ Object
- #root(path = "/", options = {}, &block) ⇒ Object
Instance Method Details
#delete(path = nil, options = {}, &block) ⇒ Object
36 37 38 |
# File 'lib/jeanine/routing/dsl.rb', line 36 def delete(path = nil, = {}, &block) router.add(:DELETE, path, , &block) end |
#get(path = nil, options = {}, &block) ⇒ Object
12 13 14 |
# File 'lib/jeanine/routing/dsl.rb', line 12 def get(path = nil, = {}, &block) router.add(:GET, path, , &block) end |
#head(path = nil, options = {}, &block) ⇒ Object
28 29 30 |
# File 'lib/jeanine/routing/dsl.rb', line 28 def head(path = nil, = {}, &block) router.add(:HEAD, path, , &block) end |
#match(path = nil, options = {}, &block) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/jeanine/routing/dsl.rb', line 49 def match(path = nil, = {}, &block) via = .delete(:via) unless via.is_a?(Array) raise RouteError, "options[:via] must be an array of HTTP verbs" end via.each do |verb| router.add(verb.upcase, path, , &block) end end |
#options(path = nil, options = {}, &block) ⇒ Object
32 33 34 |
# File 'lib/jeanine/routing/dsl.rb', line 32 def (path = nil, = {}, &block) router.add(:OPTIONS, path, , &block) end |
#patch(path = nil, options = {}, &block) ⇒ Object
24 25 26 |
# File 'lib/jeanine/routing/dsl.rb', line 24 def patch(path = nil, = {}, &block) router.add(:PATCH, path, , &block) end |
#path(pathname, options = {}, &block) ⇒ Object
40 41 42 43 |
# File 'lib/jeanine/routing/dsl.rb', line 40 def path(pathname, = {}, &block) option_merger = Jeanine::PathProxy.new(self, pathname, ) option_merger.instance_eval(&block) end |
#post(path = nil, options = {}, &block) ⇒ Object
16 17 18 |
# File 'lib/jeanine/routing/dsl.rb', line 16 def post(path = nil, = {}, &block) router.add(:POST, path, , &block) end |
#put(path = nil, options = {}, &block) ⇒ Object
20 21 22 |
# File 'lib/jeanine/routing/dsl.rb', line 20 def put(path = nil, = {}, &block) router.add(:PUT, path, , &block) end |
#root(path = "/", options = {}, &block) ⇒ Object
45 46 47 |
# File 'lib/jeanine/routing/dsl.rb', line 45 def root(path = "/", = {}, &block) router.add(:GET, path, , &block) end |