nested 0.0.30 → 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nested/one.rb +13 -3
- data/nested.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39e26e8bb789f663b4e690fa556817ae758e1ae4
|
4
|
+
data.tar.gz: a224aafd80bde5b8c5c4f8979e87e30fddd3f6af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbc5966672e6de113a9423635bf194da353f06f3b82ad143f5e5a4dc4f44165c2db7c1599cdd00b57bda46cfea90cef1056e841f17fae96c57f2e882fa9a5de1
|
7
|
+
data.tar.gz: 761f3d7b3a4dd96beea705d63d597a0956f1620761ef6e91a432a6be1208061bf727e2fe4e1fbf09a2b18b90008222e094810d03d8c1420b91fb81484e55963b
|
data/lib/nested/one.rb
CHANGED
@@ -4,9 +4,19 @@ module Nested
|
|
4
4
|
|
5
5
|
MODEL_BLOCK = Proc.new do
|
6
6
|
if @__resource.parent
|
7
|
-
instance_variable_get("@#{@__resource.parent.instance_variable_name}")
|
8
|
-
|
9
|
-
|
7
|
+
parent_model = instance_variable_get("@#{@__resource.parent.instance_variable_name}")
|
8
|
+
|
9
|
+
if parent_model.respond_to?(:where)
|
10
|
+
parent_model
|
11
|
+
.where(id: params[:"#{@__resource.parent.name.to_s.singularize.to_sym}_id"])
|
12
|
+
.first
|
13
|
+
elsif parent_model.respond_to?(:detect)
|
14
|
+
parent_model.detect do |r|
|
15
|
+
(r.is_a?(Hash) ? HashWithIndifferentAccess.new(r)[:id] : r.id).to_s == params[:"#{@__resource.parent.name.to_s.singularize.to_sym}_id"]
|
16
|
+
end
|
17
|
+
else
|
18
|
+
nil
|
19
|
+
end
|
10
20
|
else
|
11
21
|
nil
|
12
22
|
end
|
data/nested.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Zimmek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|