Module: Jeanine::Routing::DSL

Extended by:
SingleForwardable
Included in:
App
Defined in:
lib/jeanine/routing/dsl.rb

Constant Summary collapse

RouteError =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#delete(path = nil, options = {}, &block) ⇒ Object



36
37
38
# File 'lib/jeanine/routing/dsl.rb', line 36

def delete(path = nil, options = {}, &block)
  router.add(:DELETE, path, options, &block)
end

#get(path = nil, options = {}, &block) ⇒ Object



12
13
14
# File 'lib/jeanine/routing/dsl.rb', line 12

def get(path = nil, options = {}, &block)
  router.add(:GET, path, options, &block)
end

#head(path = nil, options = {}, &block) ⇒ Object



28
29
30
# File 'lib/jeanine/routing/dsl.rb', line 28

def head(path = nil, options = {}, &block)
  router.add(:HEAD, path, options, &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, options = {}, &block)
  via = options.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, options, &block)
  end
end

#options(path = nil, options = {}, &block) ⇒ Object



32
33
34
# File 'lib/jeanine/routing/dsl.rb', line 32

def options(path = nil, options = {}, &block)
  router.add(:OPTIONS, path, options, &block)
end

#patch(path = nil, options = {}, &block) ⇒ Object



24
25
26
# File 'lib/jeanine/routing/dsl.rb', line 24

def patch(path = nil, options = {}, &block)
  router.add(:PATCH, path, options, &block)
end

#path(pathname, options = {}, &block) ⇒ Object



40
41
42
43
# File 'lib/jeanine/routing/dsl.rb', line 40

def path(pathname, options = {}, &block)
  option_merger = Jeanine::PathProxy.new(self, pathname, options)
  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, options = {}, &block)
  router.add(:POST, path, options, &block)
end

#put(path = nil, options = {}, &block) ⇒ Object



20
21
22
# File 'lib/jeanine/routing/dsl.rb', line 20

def put(path = nil, options = {}, &block)
  router.add(:PUT, path, options, &block)
end

#root(path = "/", options = {}, &block) ⇒ Object



45
46
47
# File 'lib/jeanine/routing/dsl.rb', line 45

def root(path = "/", options = {}, &block)
  router.add(:GET, path, options, &block)
end