implicit_resource 0.1.0 → 0.2.0
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/README.md +2 -0
- data/lib/implicit_resource/version.rb +1 -1
- data/lib/implicit_resource.rb +9 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ace4cc5a526b957b3ef95a397c9e2b5829202c564d9489c54cf5688ebd44f35
|
4
|
+
data.tar.gz: 143cf6d2b43459d9c6109b164930cb018e3f1a23459c391be3cbc3f6582c8ee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70e3314512d8870c033138a3485e46f95bdca7fbaaeda679ccaeb0b5f45fd7dd24847c0bce32ab985bb7654b85d290de104c950d647ddc31c39b54a79001cd7
|
7
|
+
data.tar.gz: 60d95f8bf30a7aff1d924f12af6d94dc09403d5b3cf02e04ca3ec9ff3fcf3ad8c943839f9c25e2bfe4d713d300c60ed95d995c1796f7b247800b7cd3f8582e3c
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
## ImplicitResource
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/implicit_resource)
|
4
|
+
|
3
5
|
In most cases you will have the same old code in your controllers, this gem allows some very basic assumptions while giving you the option to override the behavior. This allows your controllers to be limited to just the required code.
|
4
6
|
|
5
7
|
Assumptions this code makes:
|
data/lib/implicit_resource.rb
CHANGED
@@ -35,7 +35,7 @@ module ImplicitResource
|
|
35
35
|
|
36
36
|
def resource
|
37
37
|
@resource ||= if params[:id].present?
|
38
|
-
collection.find(
|
38
|
+
collection.find(primary_key)
|
39
39
|
else
|
40
40
|
collection.new
|
41
41
|
end
|
@@ -64,4 +64,12 @@ module ImplicitResource
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
def primary_key
|
69
|
+
if model_klass.primary_key.is_a?(Array)
|
70
|
+
params.try(:extract_value, :id)
|
71
|
+
else
|
72
|
+
params[:id]
|
73
|
+
end
|
74
|
+
end
|
67
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: implicit_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kelley
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: responders
|
@@ -72,7 +72,7 @@ licenses:
|
|
72
72
|
metadata:
|
73
73
|
source_code_uri: https://github.com/codezomb/implicit_resource
|
74
74
|
homepage_uri: https://github.com/codezomb/implicit_resource
|
75
|
-
post_install_message:
|
75
|
+
post_install_message:
|
76
76
|
rdoc_options: []
|
77
77
|
require_paths:
|
78
78
|
- lib
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
90
|
rubygems_version: 3.4.19
|
91
|
-
signing_key:
|
91
|
+
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: ImplicitResource
|
94
94
|
test_files: []
|