Class: ReeRoutes::RouteBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb

Defined Under Namespace

Classes: Redirect

Instance Method Summary collapse

Constructor Details

#initializeRouteBuilder

Returns a new instance of RouteBuilder.



8
9
10
11
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 8

def initialize
  @route = ReeRoutes::Route.new
  @route.respond_to = :json
end

Instance Method Details

#action(name, from:) ⇒ Object



59
60
61
62
63
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 59

def action(name, from:)
  object = Ree.container.packages_facade.get_object(from, name)
  @route.action = object
  nil
end

#before(&proc) ⇒ Object



29
30
31
32
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 29

def before(&proc)
  @route.before = proc
  nil
end

#get_routeObject



24
25
26
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 24

def get_route
  @route
end

#override(&proc) ⇒ Object



35
36
37
38
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 35

def override(&proc)
  @route.override = proc
  nil
end

#redirect(path, code: 301) ⇒ Object

Raises:

  • (ArgumentError)


66
67
68
69
70
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 66

def redirect(path, code: 301)
  raise ArgumentError if ![301, 302, 303, 307, 308].include?(code)
  @route.redirect = Redirect.new(path, code)
  nil
end

#respond_to(v) ⇒ Object



19
20
21
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 19

def respond_to(v)
  @route.respond_to = v
end

#sections(*names) ⇒ Object



53
54
55
56
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 53

def sections(*names)
  @route.sections = names
  nil
end

#serializer(name, from:) ⇒ Object



46
47
48
49
50
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 46

def serializer(name, from:)
  object = Ree.container.packages_facade.get_object(from, name)
  @route.serializer = object
  nil
end

#summary(str) ⇒ Object



41
42
43
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 41

def summary(str)
  @route.summary = str
end

#warden_scope(scope) ⇒ Object



14
15
16
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb', line 14

def warden_scope(scope)
  @route.warden_scope = scope
end