human_routes 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/human_routes/context.rb +11 -7
- data/lib/human_routes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cfd4e06db3b929750903be57fb3a372463a25d176b79b61b8a6bf80093a099b
|
4
|
+
data.tar.gz: ef6be79a9800bf8aea869c9b6f0f80c29e74479c5e652e2f1650065fd6c67728
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e383792de96ae4117d47411b77e92cdfb2f4f8e60e28706cab505ebda709df97df543d9718a6c2575d71943cd7f88867916df01d64f7faca0c34126b5e0b6d9
|
7
|
+
data.tar.gz: db912bd53f9433f05823e8bedf9da0f285b00e9263df598bbf49524311d322283861a1b6d1585226ea2030baf83a18e79e761d4f9f033508647401206b711dc9
|
data/README.md
CHANGED
@@ -104,6 +104,13 @@ Rails.application.routes.draw do
|
|
104
104
|
route :pages, module: "customer" do
|
105
105
|
all
|
106
106
|
end
|
107
|
+
|
108
|
+
# Additionally, you can use `:name` to give a different name to
|
109
|
+
# namespaced controllers. This way routes can be generated using a shallow
|
110
|
+
# path instead of the usual `admin/reports`.
|
111
|
+
route "admin/reports", name: "reports" do
|
112
|
+
all
|
113
|
+
end
|
107
114
|
end
|
108
115
|
```
|
109
116
|
|
data/lib/human_routes/context.rb
CHANGED
@@ -10,8 +10,12 @@ module HumanRoutes
|
|
10
10
|
@options = options
|
11
11
|
end
|
12
12
|
|
13
|
+
def controller_name
|
14
|
+
@controller_name ||= options.delete(:name) { controller.to_s }
|
15
|
+
end
|
16
|
+
|
13
17
|
def singular_controller_name
|
14
|
-
@singular_controller_name ||=
|
18
|
+
@singular_controller_name ||= controller_name.singularize
|
15
19
|
end
|
16
20
|
|
17
21
|
def routes
|
@@ -20,7 +24,7 @@ module HumanRoutes
|
|
20
24
|
|
21
25
|
def create(*args)
|
22
26
|
path, name, options = extract_route_args(
|
23
|
-
default_path: "#{
|
27
|
+
default_path: "#{controller_name}/new",
|
24
28
|
default_name: "new_#{singular_controller_name}",
|
25
29
|
args: args
|
26
30
|
)
|
@@ -48,7 +52,7 @@ module HumanRoutes
|
|
48
52
|
|
49
53
|
def update(*args)
|
50
54
|
path, name, options = extract_route_args(
|
51
|
-
default_path: "#{
|
55
|
+
default_path: "#{controller_name}/:id/edit",
|
52
56
|
default_name: "edit_#{singular_controller_name}",
|
53
57
|
args: args
|
54
58
|
)
|
@@ -76,7 +80,7 @@ module HumanRoutes
|
|
76
80
|
|
77
81
|
def remove(*args)
|
78
82
|
path, name, options = extract_route_args(
|
79
|
-
default_path: "#{
|
83
|
+
default_path: "#{controller_name}/:id/remove",
|
80
84
|
default_name: "remove_#{singular_controller_name}",
|
81
85
|
args: args
|
82
86
|
)
|
@@ -104,8 +108,8 @@ module HumanRoutes
|
|
104
108
|
|
105
109
|
def list(*args)
|
106
110
|
path, name, options = extract_route_args(
|
107
|
-
default_path:
|
108
|
-
default_name:
|
111
|
+
default_path: controller_name,
|
112
|
+
default_name: controller_name,
|
109
113
|
args: args
|
110
114
|
)
|
111
115
|
|
@@ -122,7 +126,7 @@ module HumanRoutes
|
|
122
126
|
|
123
127
|
def show(*args)
|
124
128
|
path, name, options = extract_route_args(
|
125
|
-
default_path: "#{
|
129
|
+
default_path: "#{controller_name}/:id",
|
126
130
|
default_name: singular_controller_name,
|
127
131
|
args: args
|
128
132
|
)
|
data/lib/human_routes/version.rb
CHANGED