lib/chusaku/routes.rb in chusaku-0.1.4 vs lib/chusaku/routes.rb in chusaku-0.2.0
- old
+ new
@@ -7,15 +7,14 @@
# Example output:
#
# {
# 'users' => {
# 'edit' => [
- # { verb: ['GET'], path: '/users/:id', name: ['edit_user'] }],
+ # { verb: 'GET', path: '/users/:id', name: 'edit_user' }],
# 'update' => [
- # { verb: ['PUT', 'PATCH'],
- # path: '/users',
- # name: ['edit_user', 'edit_user2'] }]
+ # { verb: 'PATCH', path: '/users', name: 'edit_user' },
+ # { verb: 'PUT', path: '/users', name: 'edit_user' }]
# },
# 'empanadas' => {
# 'create' => [
# { verb: 'POST', path: '/empanadas', name: nil }]
# }
@@ -59,10 +58,10 @@
# @return {Hash} Backfilled routes
def self.backfill_routes(routes)
paths = {}
routes.each do |_controller, actions|
- actions.each do |action, data|
+ actions.each do |_action, data|
data.each do |datum|
paths[datum[:path]] ||= datum[:name]
datum[:name] ||= paths[datum[:path]]
end
end