lib/og/store.rb in og-0.25.0 vs lib/og/store.rb in og-0.26.0
- old
+ new
@@ -15,10 +15,12 @@
# :section: Store methods.
# Return the store for the given name.
def self.for_name(name)
+ Logger.info "Og uses the #{name.to_s.capitalize} store."
+
# gmosx: to keep RDoc happy.
eval %{
require 'og/store/#{name}'
return #{name.to_s.capitalize}Store
}
@@ -92,16 +94,27 @@
# Save an object to store. Insert if this is a new object or
# update if this is already inserted in the database.
def save(obj, options = nil)
+ return false unless obj.valid?
+
if obj.saved?
obj.og_update(self, options)
else
obj.og_insert(self)
end
end
alias_method :<<, :save
+ alias_method :validate_and_save, :save
+
+ def force_save!(obj, options)
+ if obj.saved?
+ obj.og_update(self, options)
+ else
+ obj.og_insert(self)
+ end
+ end
# Insert an object in the store.
def insert(obj)
obj.og_insert(self)