Module: Landline::DSL::PathConstructors

Included in:
PathContext
Defined in:
lib/landline/dsl/constructors_path.rb

Overview

Path (and subclasses) DSL constructors

Instance Method Summary collapse

Instance Method Details

#connect(path, **args, &setup) ⇒ Object

Create a new Handlers::CONNECTHandler object



70
71
72
73
74
75
# File 'lib/landline/dsl/constructors_path.rb', line 70

def connect(path, **args, &setup)
  register(Landline::Handlers::CONNECT.new(path,
                                           parent: @origin,
                                           **args,
                                           &setup))
end

#delete(path, **args, &setup) ⇒ Object

Create a new Handlers::DELETEHandler object



62
63
64
65
66
67
# File 'lib/landline/dsl/constructors_path.rb', line 62

def delete(path, **args, &setup)
  register(Landline::Handlers::DELETE.new(path,
                                          parent: @origin,
                                          **args,
                                          &setup))
end

#get(path, **args, &setup) ⇒ Object

Create a new Handlers::GETHandler object



30
31
32
33
34
35
# File 'lib/landline/dsl/constructors_path.rb', line 30

def get(path, **args, &setup)
  register(Landline::Handlers::GET.new(path,
                                       parent: @origin,
                                       **args,
                                       &setup))
end

#head(path, **args, &setup) ⇒ Object

Create a new Handlers::HEADHandler object



54
55
56
57
58
59
# File 'lib/landline/dsl/constructors_path.rb', line 54

def head(path, **args, &setup)
  register(Landline::Handlers::HEAD.new(path,
                                        parent: @origin,
                                        **args,
                                        &setup))
end

#options(path, **args, &setup) ⇒ Object

Create a new Handlers::OPTIONSHandler object



94
95
96
97
98
99
# File 'lib/landline/dsl/constructors_path.rb', line 94

def options(path, **args, &setup)
  register(Landline::Handlers::OPTIONS.new(path,
                                           parent: @origin,
                                           **args,
                                           &setup))
end

#patch(path, **args, &setup) ⇒ Object

Create a new Handlers::PATCHHandler object



86
87
88
89
90
91
# File 'lib/landline/dsl/constructors_path.rb', line 86

def patch(path, **args, &setup)
  register(Landline::Handlers::PATCH.new(path,
                                         parent: @origin,
                                         **args,
                                         &setup))
end

#path(path, **args, &setup) ⇒ Object

Create a new Path object



18
19
20
# File 'lib/landline/dsl/constructors_path.rb', line 18

def path(path, **args, &setup)
  register(Landline::Path.new(path, parent: @origin, **args, &setup))
end

#post(path, **args, &setup) ⇒ Object

create a new Handlers::POSTHandler object



38
39
40
41
42
43
# File 'lib/landline/dsl/constructors_path.rb', line 38

def post(path, **args, &setup)
  register(Landline::Handlers::POST.new(path,
                                        parent: @origin,
                                        **args,
                                        &setup))
end

#probe(path, **args, &_setup) ⇒ Object

Create a new Handlers::Probe object



23
24
25
26
27
# File 'lib/landline/dsl/constructors_path.rb', line 23

def probe(path, **args, &_setup)
  register(Landline::Handlers::Probe.new(path,
                                         parent: @origin,
                                         **args))
end

#put(path, **args, &setup) ⇒ Object

Create a new Handlers::PUTHandler object



46
47
48
49
50
51
# File 'lib/landline/dsl/constructors_path.rb', line 46

def put(path, **args, &setup)
  register(Landline::Handlers::PUT.new(path,
                                       parent: @origin,
                                       **args,
                                       &setup))
end

#register(obj) ⇒ Object

Append a Node child object to the list of children



9
10
11
12
13
14
15
# File 'lib/landline/dsl/constructors_path.rb', line 9

def register(obj)
  unless obj.is_a? Landline::Node
    raise ArgumentError, "register accepts node children only"
  end

  @origin.children.append(obj)
end

#serve(path) ⇒ Object

Create a new Handlers::GETHandler that serves static files



102
103
104
# File 'lib/landline/dsl/constructors_path.rb', line 102

def serve(path)
  register(Landline::Handlers::Serve.new(path, parent: @origin))
end

#trace(path, **args, &setup) ⇒ Object

Create a new Handlers::TRACEHandler object



78
79
80
81
82
83
# File 'lib/landline/dsl/constructors_path.rb', line 78

def trace(path, **args, &setup)
  register(Landline::Handlers::TRACE.new(path,
                                         parent: @origin,
                                         **args,
                                         &setup))
end