Module: Gitlab::Patch::DrawRoute

Defined in:
lib/gitlab/patch/draw_route.rb

Constant Summary collapse

RoutesNotFound =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#draw(routes_name) ⇒ Object


10
11
12
13
14
# File 'lib/gitlab/patch/draw_route.rb', line 10

def draw(routes_name)
  drawn_any = draw_ee(routes_name) | draw_ce(routes_name)

  drawn_any || raise(RoutesNotFound, "Cannot find #{routes_name}")
end

#draw_ce(routes_name) ⇒ Object


16
17
18
# File 'lib/gitlab/patch/draw_route.rb', line 16

def draw_ce(routes_name)
  draw_route(route_path("config/routes/#{routes_name}.rb"))
end

#draw_ee(_) ⇒ Object


20
21
22
# File 'lib/gitlab/patch/draw_route.rb', line 20

def draw_ee(_)
  true
end

#draw_route(path) ⇒ Object


28
29
30
31
32
33
34
35
# File 'lib/gitlab/patch/draw_route.rb', line 28

def draw_route(path)
  if File.exist?(path)
    instance_eval(File.read(path))
    true
  else
    false
  end
end

#route_path(routes_name) ⇒ Object


24
25
26
# File 'lib/gitlab/patch/draw_route.rb', line 24

def route_path(routes_name)
  Rails.root.join(routes_name)
end