simple_record 1.1.49 → 1.1.51
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_record.rb +4 -2
- data/lib/simple_record/attributes.rb +10 -3
- data/lib/simple_record/translations.rb +0 -1
- data/test/test_simple_record.rb +4 -0
- metadata +1 -1
data/lib/simple_record.rb
CHANGED
@@ -540,10 +540,12 @@ module SimpleRecord
|
|
540
540
|
end
|
541
541
|
attvalue = strip_array(attvalue)
|
542
542
|
make_dirty(attname, attvalue)
|
543
|
-
|
543
|
+
puts "ARG=#{attname.to_s} setting to #{attvalue}"
|
544
544
|
sdb_val = ruby_to_sdb(name, attvalue)
|
545
|
+
puts "sdb_val=" + sdb_val.to_s
|
545
546
|
@attributes[attname] = sdb_val
|
546
|
-
attvalue = wrap_if_required(name,
|
547
|
+
attvalue = wrap_if_required(name, attvalue, sdb_val)
|
548
|
+
puts 'attvalue2=' + attvalue.to_s
|
547
549
|
@attributes_rb[attname] = attvalue
|
548
550
|
|
549
551
|
# instance_var = "@" + attname.to_s
|
@@ -180,8 +180,16 @@ module SimpleRecord
|
|
180
180
|
|
181
181
|
# Define ID reader method for reading the associated objects id without getting the entire object
|
182
182
|
send(:define_method, arg_id) do
|
183
|
-
|
184
|
-
|
183
|
+
val1 = @attributes[arg_id]
|
184
|
+
if val1
|
185
|
+
if val1.is_a?(Array)
|
186
|
+
if val1.size > 0 && val1[0].present?
|
187
|
+
return val1[0]
|
188
|
+
end
|
189
|
+
|
190
|
+
else
|
191
|
+
return val1
|
192
|
+
end
|
185
193
|
end
|
186
194
|
return nil
|
187
195
|
end
|
@@ -224,7 +232,6 @@ module SimpleRecord
|
|
224
232
|
end
|
225
233
|
|
226
234
|
|
227
|
-
|
228
235
|
def self.handle_virtuals(attrs)
|
229
236
|
@@virtuals.each do |virtual|
|
230
237
|
#we first copy the information for the virtual to an instance variable of the same name
|
data/test/test_simple_record.rb
CHANGED
@@ -99,7 +99,11 @@ class TestSimpleRecord < TestBase
|
|
99
99
|
child = MyChildModel.new
|
100
100
|
child.name = "Child"
|
101
101
|
child.my_model = mm
|
102
|
+
puts 'c1=' + child.inspect
|
103
|
+
puts 'mmid1=' + child.my_model_id.to_s
|
104
|
+
assert child.my_model_id == mm.id
|
102
105
|
child.save
|
106
|
+
puts 'mmid2=' + child.my_model_id.to_s
|
103
107
|
|
104
108
|
puts "child=" + child.inspect
|
105
109
|
sleep 1
|