Class: Shakha::Engine::EngineRouter::Drawer

Inherits:
Object
  • Object
show all
Defined in:
lib/shakha/engine.rb

Instance Method Summary collapse

Constructor Details

#initializeDrawer

Returns a new instance of Drawer.



23
24
25
# File 'lib/shakha/engine.rb', line 23

def initialize
  @routes = []
end

Instance Method Details

#get(path, to:, as: nil) ⇒ Object



41
42
43
# File 'lib/shakha/engine.rb', line 41

def get(path, to:, as: nil)
  @routes << { type: :get, path: path, to: to, as: as }
end

#match(path, to:, via:, as: nil) ⇒ Object



49
50
51
# File 'lib/shakha/engine.rb', line 49

def match(path, to:, via:, as: nil)
  @routes << { type: :match, path: path, to: to, via: via, as: as }
end

#post(path, to:, as: nil) ⇒ Object



45
46
47
# File 'lib/shakha/engine.rb', line 45

def post(path, to:, as: nil)
  @routes << { type: :post, path: path, to: to, as: as }
end

#resource(*args, &block) ⇒ Object



34
35
36
37
38
39
# File 'lib/shakha/engine.rb', line 34

def resource(*args, &block)
  resource_options = args.last.is_a?(Hash) ? args.pop : {}
  resource_name = args.first

  @routes << { type: :resource, name: resource_name, options: resource_options, block: block }
end

#resources(*args, &block) ⇒ Object



27
28
29
30
31
32
# File 'lib/shakha/engine.rb', line 27

def resources(*args, &block)
  resource_options = args.last.is_a?(Hash) ? args.pop : {}
  resource_name = args.first

  @routes << { type: :resources, name: resource_name, options: resource_options, block: block }
end

#routesObject



53
54
55
# File 'lib/shakha/engine.rb', line 53

def routes
  @routes
end