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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cd6ad0e6c6212045d4b6d3fb2eec3ca9c901d4624533f7ed9fa7f2feedc179b
4
- data.tar.gz: b4efa30d7b1c6a7706be07ee362d0cfb600dbd4f53a3cfe44f12b42cc9f8bfc9
3
+ metadata.gz: 4ace4cc5a526b957b3ef95a397c9e2b5829202c564d9489c54cf5688ebd44f35
4
+ data.tar.gz: 143cf6d2b43459d9c6109b164930cb018e3f1a23459c391be3cbc3f6582c8ee3
5
5
  SHA512:
6
- metadata.gz: 4044df37cf13a185176605427545fee16359ffa68eb8d0b1f88e31355b815b3634fa0af163aa15f4c932f31e36beefe5c522af7582244b47649b30426c4a2292
7
- data.tar.gz: 9af3ce0fe668ca9b748f744d759b2f3f47a306bf3cda310f24ddca4341b10084e502e9490d2d010bcdbbf44bfda64914239fa7cd78a5187956bfa380f0a8802a
6
+ metadata.gz: f70e3314512d8870c033138a3485e46f95bdca7fbaaeda679ccaeb0b5f45fd7dd24847c0bce32ab985bb7654b85d290de104c950d647ddc31c39b54a79001cd7
7
+ data.tar.gz: 60d95f8bf30a7aff1d924f12af6d94dc09403d5b3cf02e04ca3ec9ff3fcf3ad8c943839f9c25e2bfe4d713d300c60ed95d995c1796f7b247800b7cd3f8582e3c
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ## ImplicitResource
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/implicit_resource.svg)](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:
@@ -1,3 +1,3 @@
1
1
  module ImplicitResource
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -35,7 +35,7 @@ module ImplicitResource
35
35
 
36
36
  def resource
37
37
  @resource ||= if params[:id].present?
38
- collection.find(params[:id])
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.1.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-03-29 00:00:00.000000000 Z
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: []