Class: Shakha::Engine::EngineRouter::Drawer
- Inherits:
-
Object
- Object
- Shakha::Engine::EngineRouter::Drawer
- Defined in:
- lib/shakha/engine.rb
Instance Method Summary collapse
- #get(path, to:, as: nil) ⇒ Object
-
#initialize ⇒ Drawer
constructor
A new instance of Drawer.
- #match(path, to:, via:, as: nil) ⇒ Object
- #post(path, to:, as: nil) ⇒ Object
- #resource(*args, &block) ⇒ Object
- #resources(*args, &block) ⇒ Object
- #routes ⇒ Object
Constructor Details
#initialize ⇒ Drawer
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) = args.last.is_a?(Hash) ? args.pop : {} resource_name = args.first @routes << { type: :resource, name: resource_name, 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) = args.last.is_a?(Hash) ? args.pop : {} resource_name = args.first @routes << { type: :resources, name: resource_name, options: , block: block } end |
#routes ⇒ Object
53 54 55 |
# File 'lib/shakha/engine.rb', line 53 def routes @routes end |