Class: Seahorse::Router
- Inherits:
-
Object
- Object
- Seahorse::Router
- Defined in:
- lib/seahorse/router.rb
Instance Method Summary collapse
- #add_routes(router) ⇒ Object
-
#initialize(model) ⇒ Router
constructor
A new instance of Router.
Constructor Details
#initialize(model) ⇒ Router
Returns a new instance of Router.
3 4 5 |
# File 'lib/seahorse/router.rb', line 3 def initialize(model) @model = model end |
Instance Method Details
#add_routes(router) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/seahorse/router.rb', line 7 def add_routes(router) operations = @model.operations controller = @model.model_name.pluralize operations.each do |name, operation| router.match "/#{name}" => "#{controller}##{operation.action}", defaults: { format: 'json' }, via: [:get, operation.verb.to_sym].uniq router.match operation.url => "#{controller}##{operation.action}", defaults: { format: 'json' }, via: operation.verb end end |