belt 0.3.39 → 0.3.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/lib/belt/route_dsl.rb +15 -12
- data/lib/belt/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: 848174ed726800ea7e2a60b16a43714e558bf8adae32017a195a4ef0982cff11
|
|
4
|
+
data.tar.gz: 3d71874ef9d72422b72059e768de032b07caeb9b719bfaaf307d5d4d634b48ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f431f7d645a3e94cdbf799f0d6fdd44a817491fd991da85b3bce7df95e760359638b1eeb528b39f3dc33edc51a324f4d0a4627152e0e4c025749020b3549ab91
|
|
7
|
+
data.tar.gz: 59fc7c275194d8ac49c4f69a0eb0109dcdf516eb1f6f597d5c7a9a5f0e16046d2d0dd6c88920c94c58735e643a0e231b3ce331fa919a7bc1d240c91ecb710c2f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.40
|
|
4
|
+
|
|
5
|
+
### Breaking Change
|
|
6
|
+
|
|
7
|
+
- **Rails-style `{id}` for member routes**: Member routes (show, update, destroy)
|
|
8
|
+
now use `{id}` instead of `{singular_id}`. This matches Rails conventions where
|
|
9
|
+
the resource being operated on uses `:id`, and only parent resources use prefixed
|
|
10
|
+
names like `:project_id`.
|
|
11
|
+
|
|
12
|
+
Before:
|
|
13
|
+
```
|
|
14
|
+
GET /projects/{project_id}
|
|
15
|
+
GET /projects/{project_id}/epics/{epic_id}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
After:
|
|
19
|
+
```
|
|
20
|
+
GET /projects/{id}
|
|
21
|
+
GET /projects/{project_id}/epics/{id}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Parent resources in nested routes still use `{singular_id}` (e.g., `{project_id}`,
|
|
25
|
+
`{epic_id}` when they are parents of nested resources).
|
|
26
|
+
|
|
3
27
|
## 0.3.39
|
|
4
28
|
|
|
5
29
|
### Enhancement
|
data/lib/belt/route_dsl.rb
CHANGED
|
@@ -251,7 +251,8 @@ module Belt
|
|
|
251
251
|
end
|
|
252
252
|
end
|
|
253
253
|
|
|
254
|
-
def add_nested_resource_routes(resource_name,
|
|
254
|
+
def add_nested_resource_routes(resource_name, _param_name, resource_options, actions)
|
|
255
|
+
# Member routes (show/update/destroy) use {id}, not {singular_id} — Rails convention
|
|
255
256
|
if actions.include?(:index)
|
|
256
257
|
@gateway.send(:add_route, :get, "#{@prefix}/#{resource_name}",
|
|
257
258
|
resolve_request_model_for(resource_options, :index))
|
|
@@ -261,16 +262,16 @@ module Belt
|
|
|
261
262
|
resolve_request_model_for(resource_options, :create))
|
|
262
263
|
end
|
|
263
264
|
if actions.include?(:show)
|
|
264
|
-
@gateway.send(:add_route, :get, "#{@prefix}/#{resource_name}/{
|
|
265
|
+
@gateway.send(:add_route, :get, "#{@prefix}/#{resource_name}/{id}",
|
|
265
266
|
resolve_request_model_for(resource_options, :show))
|
|
266
267
|
end
|
|
267
268
|
if actions.include?(:update)
|
|
268
|
-
@gateway.send(:add_route, :put, "#{@prefix}/#{resource_name}/{
|
|
269
|
+
@gateway.send(:add_route, :put, "#{@prefix}/#{resource_name}/{id}",
|
|
269
270
|
resolve_request_model_for(resource_options, :update))
|
|
270
271
|
end
|
|
271
272
|
return unless actions.include?(:destroy)
|
|
272
273
|
|
|
273
|
-
@gateway.send(:add_route, :delete, "#{@prefix}/#{resource_name}/{
|
|
274
|
+
@gateway.send(:add_route, :delete, "#{@prefix}/#{resource_name}/{id}",
|
|
274
275
|
resolve_request_model_for(resource_options, :destroy))
|
|
275
276
|
end
|
|
276
277
|
|
|
@@ -496,7 +497,8 @@ module Belt
|
|
|
496
497
|
options.merge(tables: [resource_name.to_sym])
|
|
497
498
|
end
|
|
498
499
|
|
|
499
|
-
def add_resource_routes(resource_name,
|
|
500
|
+
def add_resource_routes(resource_name, _param_name, resource_options, actions)
|
|
501
|
+
# Member routes (show/update/destroy) use {id}, not {singular_id} — Rails convention
|
|
500
502
|
if actions.include?(:index)
|
|
501
503
|
add_route(:get, "/#{resource_name}",
|
|
502
504
|
resolve_request_model_for(resource_options, :index))
|
|
@@ -506,16 +508,16 @@ module Belt
|
|
|
506
508
|
resolve_request_model_for(resource_options, :create))
|
|
507
509
|
end
|
|
508
510
|
if actions.include?(:show)
|
|
509
|
-
add_route(:get, "/#{resource_name}/{
|
|
511
|
+
add_route(:get, "/#{resource_name}/{id}",
|
|
510
512
|
resolve_request_model_for(resource_options, :show))
|
|
511
513
|
end
|
|
512
514
|
if actions.include?(:update)
|
|
513
|
-
add_route(:put, "/#{resource_name}/{
|
|
515
|
+
add_route(:put, "/#{resource_name}/{id}",
|
|
514
516
|
resolve_request_model_for(resource_options, :update))
|
|
515
517
|
end
|
|
516
518
|
return unless actions.include?(:destroy)
|
|
517
519
|
|
|
518
|
-
add_route(:delete, "/#{resource_name}/{
|
|
520
|
+
add_route(:delete, "/#{resource_name}/{id}", resolve_request_model_for(resource_options, :destroy))
|
|
519
521
|
end
|
|
520
522
|
|
|
521
523
|
def resolve_request_model_for(options, action)
|
|
@@ -797,7 +799,8 @@ module Belt
|
|
|
797
799
|
end
|
|
798
800
|
end
|
|
799
801
|
|
|
800
|
-
def add_scoped_resource_routes(resource_name,
|
|
802
|
+
def add_scoped_resource_routes(resource_name, _param_name, resource_options, actions)
|
|
803
|
+
# Member routes (show/update/destroy) use {id}, not {singular_id} — Rails convention
|
|
801
804
|
if actions.include?(:index)
|
|
802
805
|
@gateway.send(:add_route, :get, build_path("/#{resource_name}"),
|
|
803
806
|
resolve_request_model_for(resource_options, :index))
|
|
@@ -807,16 +810,16 @@ module Belt
|
|
|
807
810
|
resolve_request_model_for(resource_options, :create))
|
|
808
811
|
end
|
|
809
812
|
if actions.include?(:show)
|
|
810
|
-
@gateway.send(:add_route, :get, build_path("/#{resource_name}/{
|
|
813
|
+
@gateway.send(:add_route, :get, build_path("/#{resource_name}/{id}"),
|
|
811
814
|
resolve_request_model_for(resource_options, :show))
|
|
812
815
|
end
|
|
813
816
|
if actions.include?(:update)
|
|
814
|
-
@gateway.send(:add_route, :put, build_path("/#{resource_name}/{
|
|
817
|
+
@gateway.send(:add_route, :put, build_path("/#{resource_name}/{id}"),
|
|
815
818
|
resolve_request_model_for(resource_options, :update))
|
|
816
819
|
end
|
|
817
820
|
return unless actions.include?(:destroy)
|
|
818
821
|
|
|
819
|
-
@gateway.send(:add_route, :delete, build_path("/#{resource_name}/{
|
|
822
|
+
@gateway.send(:add_route, :delete, build_path("/#{resource_name}/{id}"),
|
|
820
823
|
resolve_request_model_for(resource_options, :destroy))
|
|
821
824
|
end
|
|
822
825
|
|
data/lib/belt/version.rb
CHANGED