lib/csv_pirate.rb in csv_pirate-4.0.2 vs lib/csv_pirate.rb in csv_pirate-4.0.3
- old
+ new
@@ -349,25 +349,25 @@
obj = self.grub.new(data_hash)
obj.save(false) if obj.respond_to?(:save)
end
buccaneers << obj
elsif permanence[:find_or_create]
- obj = self.grub.send("find_by_#{permanence[:find_or_create].join('_and_')}".to_sym)
- buccaneers << obj || self.grub.create(data_hash)
+ obj = self.grub.send("find_by_#{permanence[:find_or_create].join('_and_')}".to_sym) || self.grub.create(data_hash)
+ buccaneers << obj
elsif permanence[:update_or_new]
- obj = self.grub.send("find_by_#{permanence[:find_or_new].join('_and_')}".to_sym)
+ obj = self.grub.send("find_by_#{permanence[:update_or_new].join('_and_')}".to_sym)
if obj.nil?
obj = self.grub.new(data_hash)
else
data_hash.each do |k,v|
obj.send("#{k}=".to_sym, v)
obj.save(false)
end
end
buccaneers << obj
elsif permanence[:update_or_save]
- obj = self.grub.send("find_by_#{permanence[:find_or_new].join('_and_')}".to_sym)
+ obj = self.grub.send("find_by_#{permanence[:update_or_save].join('_and_')}".to_sym)
if obj.nil?
obj = self.grub.new(data_hash)
obj.save(false)
else
data_hash.each do |k,v|
@@ -375,10 +375,10 @@
obj.save(false)
end
end
buccaneers << obj
elsif permanence[:update_or_create]
- obj = self.grub.send("find_by_#{permanence[:find_or_new].join('_and_')}".to_sym)
+ obj = self.grub.send("find_by_#{permanence[:update_or_create].join('_and_')}".to_sym)
if obj.nil?
obj = self.grub.create(data_hash)
else
data_hash.each do |k,v|
obj.send("#{k}=".to_sym, v)