dcidev_active_record 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dcidev_active_record.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39ef130c33dba54d43cb868680de1a87e6a21fdd0aa1ec784231b0faad38e998
|
4
|
+
data.tar.gz: 51bb74f205875eba8875bf1136e8c53ae4b61ef0bf7587224603e809f477ea0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6be9964e2b1fee13e235bb9c6ca21dfc9fb2e472cb425ef9afe47e1d2175194c93138b2965c02fca6276ed1a7dd45e9f6b17fc797952cb2044c671888d3f20d
|
7
|
+
data.tar.gz: 6d5d16730a92f8b577ae7b1d181cd888842590778e74156e292450b9954c1fed0954b6d60c6300b112b4a08fbde85de5922ae6835039f81f3f8a5dbf7f7facae
|
data/lib/dcidev_active_record.rb
CHANGED
@@ -118,6 +118,20 @@ module DcidevActiveRecord
|
|
118
118
|
return 'LIKE' if db == 'mysql'
|
119
119
|
end
|
120
120
|
end
|
121
|
+
|
122
|
+
def init_nested_attributes(reflections)
|
123
|
+
reflections.each do |r|
|
124
|
+
define_method("#{r}_attributes=") do |attr|
|
125
|
+
if attr.present?
|
126
|
+
children = []
|
127
|
+
attr.each do |child|
|
128
|
+
children << r.classify.constantize.find_or_initialize_by(child)
|
129
|
+
end
|
130
|
+
eval("self.#{r} = children")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
121
135
|
end
|
122
136
|
|
123
137
|
ActiveRecord::Base.send(:include, DcidevActiveRecord)
|