activerecord-bixformer 0.4.5 → 0.4.6
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: ebdeb4d0ee7e10859c4a8d348ebcc505bf286d19
|
4
|
+
data.tar.gz: 805e0d16206bd0b33fad2e78dd412a3c300541d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b179a6a9c55b795c791fdb8e746d9b05e772f32dbd2f3241d52da8e36c96e2945b011eb38fe9309a5410e341e0bd46989c4165144f43882142dae3da980c318
|
7
|
+
data.tar.gz: 41e2e7330629c0d28fd899e587a3bf0264e128d1c23b9d48f1fb3bdbc5dafa1a8e5a1a3995f3e83bfc15f06b99209d7a007cebfbcd40e61d365f05338a8af766
|
@@ -39,10 +39,10 @@ module ActiveRecord
|
|
39
39
|
def import(value)
|
40
40
|
return nil unless value.present?
|
41
41
|
|
42
|
-
parser
|
43
|
-
find_by
|
44
|
-
scope
|
45
|
-
creator
|
42
|
+
parser = @options[:parser]
|
43
|
+
find_by = @options[:find_by]
|
44
|
+
scope = @options[:scope] || :all
|
45
|
+
creator = @options[:creator] || :save
|
46
46
|
|
47
47
|
condition = if parser.is_a?(::Proc)
|
48
48
|
parser.call(value)
|
@@ -60,8 +60,14 @@ module ActiveRecord
|
|
60
60
|
|
61
61
|
foreign_record = if find_by.is_a?(::Proc)
|
62
62
|
find_by.call(scoped_relation, condition)
|
63
|
-
|
63
|
+
elsif find_by
|
64
64
|
scoped_relation.__send__(find_by, condition)
|
65
|
+
elsif scoped_relation.respond_to?(:find_by)
|
66
|
+
scoped_relation.find_by(condition)
|
67
|
+
else
|
68
|
+
scoped_relation.find do |r|
|
69
|
+
condition.all? { |k, v| r.__send__(k) == v rescue false }
|
70
|
+
end
|
65
71
|
end
|
66
72
|
|
67
73
|
if ! foreign_record && @options[:create]
|