lib/ohm.rb in ohm-0.0.6 vs lib/ohm.rb in ohm-0.0.7

- old
+ new

@@ -156,19 +156,24 @@ attrs.each do |key, value| send(:"#{key}=", value) end end + def new? + !id + end + def create return unless valid? initialize_id create_model_membership add_to_indices save! end def save + create if new? return unless valid? update_indices save! end @@ -199,10 +204,10 @@ end protected def key(*args) - raise ModelIsNew unless id + raise ModelIsNew if new? self.class.key(id, *args) end private