Class: Jun::ActionDispatch::Routing::Mapper
- Defined in:
- lib/jun/action_dispatch/routing/mapper.rb
Instance Method Summary collapse
- #delete(path, to:, as: nil) ⇒ Object
- #get(path, to:, as: nil) ⇒ Object
-
#initialize(route_set) ⇒ Mapper
constructor
A new instance of Mapper.
- #patch(path, to:, as: nil) ⇒ Object
- #post(path, to:, as: nil) ⇒ Object
- #resources(plural_name) ⇒ Object
- #root(to:) ⇒ Object
Constructor Details
#initialize(route_set) ⇒ Mapper
Returns a new instance of Mapper.
7 8 9 |
# File 'lib/jun/action_dispatch/routing/mapper.rb', line 7 def initialize(route_set) @route_set = route_set end |
Instance Method Details
#delete(path, to:, as: nil) ⇒ Object
23 24 25 |
# File 'lib/jun/action_dispatch/routing/mapper.rb', line 23 def delete(path, to:, as: nil) add_route(:delete, path, to: to, as: as) end |
#get(path, to:, as: nil) ⇒ Object
11 12 13 |
# File 'lib/jun/action_dispatch/routing/mapper.rb', line 11 def get(path, to:, as: nil) add_route(:get, path, to: to, as: as) end |
#patch(path, to:, as: nil) ⇒ Object
19 20 21 |
# File 'lib/jun/action_dispatch/routing/mapper.rb', line 19 def patch(path, to:, as: nil) add_route(:patch, path, to: to, as: as) end |
#post(path, to:, as: nil) ⇒ Object
15 16 17 |
# File 'lib/jun/action_dispatch/routing/mapper.rb', line 15 def post(path, to:, as: nil) add_route(:post, path, to: to, as: as) end |
#resources(plural_name) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/jun/action_dispatch/routing/mapper.rb', line 31 def resources(plural_name) get "/#{plural_name}", to: "#{plural_name}#index", as: plural_name.to_s get "/#{plural_name}/new", to: "#{plural_name}#new", as: "new_#{plural_name.to_s.singularize}" post "/#{plural_name}", to: "#{plural_name}#create" get "/#{plural_name}/:id", to: "#{plural_name}#show", as: plural_name.to_s.singularize get "/#{plural_name}/:id/edit", to: "#{plural_name}#edit", as: "edit_#{plural_name.to_s.singularize}" patch "/#{plural_name}/:id", to: "#{plural_name}#update" delete "/#{plural_name}/:id", to: "#{plural_name}#destroy" end |