lib/mongoo/core.rb in mongoo-0.4.6 vs lib/mongoo/core.rb in mongoo-0.4.7
- old
+ new
@@ -110,9 +110,15 @@
mongohash.dot_set(k.to_s,v); v
end
alias :set :set_attribute
alias :s :set_attribute
+ def get_or_set_attribute(k, v)
+ get_attribute(k) || set_attribute(k, v)
+ end
+ alias :get_or_set :get_or_set_attribute
+ alias :gs :get_or_set_attribute
+
def unset_attribute(k)
mongohash.dot_delete(k); true
end
alias :unset :unset_attribute
alias :u :unset_attribute
\ No newline at end of file