appoxy-simple_record 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/simple_record.rb +11 -0
- metadata +2 -2
data/lib/simple_record.rb
CHANGED
@@ -232,6 +232,7 @@ module SimpleRecord
|
|
232
232
|
return nil
|
233
233
|
end
|
234
234
|
|
235
|
+
|
235
236
|
# Define writer method
|
236
237
|
send(:define_method, arg.to_s + "=") do |value|
|
237
238
|
arg_id = arg.to_s + '_id'
|
@@ -242,6 +243,16 @@ module SimpleRecord
|
|
242
243
|
end
|
243
244
|
end
|
244
245
|
|
246
|
+
|
247
|
+
# Define writer method for setting the _id directly without the associated object
|
248
|
+
send(:define_method, arg_id + "=") do |value|
|
249
|
+
if value.nil?
|
250
|
+
self[arg_id] = nil unless self[arg_id].nil? # if it went from something to nil, then we have to remember and remove attribute on save
|
251
|
+
else
|
252
|
+
self[arg_id] = value
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
245
256
|
send(:define_method, "create_"+arg.to_s) do |*params|
|
246
257
|
newsubrecord=eval(arg.to_s.classify).new(*params)
|
247
258
|
newsubrecord.save
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appoxy-simple_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-06-
|
13
|
+
date: 2009-06-25 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|