activerecord-bixformer 0.3.10 → 0.3.11
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: 03b0d7b8164b9a2d8df5a3b32a1e6f360a70ef3f
|
4
|
+
data.tar.gz: 8c3134805d7d5ac55d0a9d4905ff3a461a1c07ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5fb1111352e1fe5839f74b477944f64c1072f671d3a65243391e73ce6c72a1879bd22cdb02d4c41e0fc1ec786c2f3ecfb644fb3d2949a1bbb76071364f7866f
|
7
|
+
data.tar.gz: f848f2b7b9ad05f9bb235cabca4a8dacb76880527cc4f297385612e10c63bd3cc2d783aa56da99a049ed67f81150b81d383b97497ceadbaa3d465911a6662a5b
|
@@ -30,7 +30,7 @@ module ActiveRecord
|
|
30
30
|
formatter = @options[:by]
|
31
31
|
|
32
32
|
if formatter.is_a?(::Proc)
|
33
|
-
|
33
|
+
formatter.call(foreign_record)
|
34
34
|
else
|
35
35
|
foreign_record.__send__(formatter)
|
36
36
|
end
|
@@ -39,13 +39,13 @@ module ActiveRecord
|
|
39
39
|
def import(value)
|
40
40
|
return nil unless value.present?
|
41
41
|
|
42
|
-
find_by
|
43
|
-
scope
|
44
|
-
finder
|
45
|
-
creator
|
42
|
+
find_by = @options[:find_by]
|
43
|
+
scope = @options[:scope] || :all
|
44
|
+
finder = @options[:finder] || :find_by
|
45
|
+
creator = @options[:creator] || :save
|
46
46
|
|
47
47
|
condition = if find_by.is_a?(::Proc)
|
48
|
-
|
48
|
+
find_by.call(value)
|
49
49
|
else
|
50
50
|
{ find_by => value }
|
51
51
|
end
|
@@ -53,20 +53,20 @@ module ActiveRecord
|
|
53
53
|
return nil unless condition
|
54
54
|
|
55
55
|
foreign_record = if scope.is_a?(::Proc)
|
56
|
-
|
56
|
+
scope.call.__send__(finder, condition)
|
57
57
|
else
|
58
58
|
foreign_constant.__send__(scope).__send__(finder, condition)
|
59
59
|
end
|
60
60
|
|
61
61
|
if ! foreign_record && @options[:create]
|
62
62
|
foreign_record = if scope.is_a?(::Proc)
|
63
|
-
|
63
|
+
scope.call.build(condition)
|
64
64
|
else
|
65
65
|
foreign_constant.__send__(scope).build(condition)
|
66
66
|
end
|
67
67
|
|
68
68
|
if creator.is_a?(::Proc)
|
69
|
-
|
69
|
+
creator.call(foreign_record)
|
70
70
|
else
|
71
71
|
foreign_record.__send__(creator)
|
72
72
|
end
|