resourcerer 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efd793cb62e4dc4237140caaafc4788f90d7512b
|
4
|
+
data.tar.gz: 8c2cb136555283429df108083d70301283c8aca9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f7710479b0c98397f045ca492d2f30a6465630fbabc8a22b6cdbb0cf64a515aad3845ab66246d9989f528b8000ef98f185d828c0c6eb22e42089755ca9c9919
|
7
|
+
data.tar.gz: 291983c1a28aafabe478019f8e24c5bd5b9ce774085c3482579db82252a2fa36495abfbf54646bde5803e165e68ed8e91ab34f5eb4f2baee304fccec5c3c2d22
|
data/README.md
CHANGED
@@ -152,7 +152,7 @@ resource(:employee, model: :person, finder_attribute: :name, finder: ->(name){ c
|
|
152
152
|
The DSL is more convenient when you have an object oriented design and want to allow an object to handle its collections, or as a quick way to set the StrongParameters method.
|
153
153
|
|
154
154
|
Configuration options play well together, and the defaults try to make intelligent use of them. For example,
|
155
|
-
setting the `finder_attribute` in the example
|
155
|
+
setting the `finder_attribute` in the example above changes the `finder_param` to `person_name` instead of `person_id`, and the value of that parameter is provided to the finder block.
|
156
156
|
|
157
157
|
### Setting a distinct object for a single action
|
158
158
|
|
@@ -23,11 +23,17 @@ module Resourcerer
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def find_resource(id)
|
26
|
-
config.finder
|
26
|
+
controller_eval(config.finder, id) || model.find_by(finder_attribute => id)
|
27
27
|
end
|
28
28
|
|
29
29
|
def build_resource
|
30
|
-
config.builder
|
30
|
+
controller_eval(config.builder) || model.new
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def controller_eval(proc, *args)
|
36
|
+
controller.instance_exec(*args, &proc) if proc
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resourcerer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Máximo Mussini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|