lib/squares/base.rb in squares-0.2.4 vs lib/squares/base.rb in squares-0.2.5
- old
+ new
@@ -53,18 +53,18 @@
def []= *args
id, instance = *args
if instance.class == self
instance.id = id
- instance.save
elsif instance.respond_to?(:to_h)
- self.new(id, instance).save
+ instance = self.new(id, instance)
else
raise ArgumentError.new(<<-ERR)
You must provide an instance of #{self.name} or at least
something which responds to #to_h"
ERR
end
+ instance.tap { |i| i.save }
end
alias_method :create, :[]=
def has_key? key
store.has_key? key