lib/ohm.rb in ohm-3.0.2 vs lib/ohm.rb in ohm-3.0.3
- old
+ new
@@ -1332,14 +1332,20 @@
# u.kind_of?(User)
# # => true
#
def save
indices = {}
- model.indices.each { |field| indices[field] = Array(send(field)).map(&:to_s) }
+ model.indices.each do |field|
+ next unless (value = send(field))
+ indices[field] = Array(value).map(&:to_s)
+ end
uniques = {}
- model.uniques.each { |field| uniques[field] = send(field).to_s }
+ model.uniques.each do |field|
+ next unless (value = send(field))
+ uniques[field] = value.to_s
+ end
features = {
"name" => model.name
}
@@ -1365,10 +1371,13 @@
#
# If the model has uniques or indices, they're also cleaned up.
#
def delete
uniques = {}
- model.uniques.each { |field| uniques[field] = send(field) }
+ model.uniques.each do |field|
+ next unless (value = send(field))
+ uniques[field] = value.to_s
+ end
script(LUA_DELETE, 0,
{ "name" => model.name,
"id" => id,
"key" => key