# File lib/og/meta.rb, line 117 def has_one(name, klass = nil, options = {}) # linkback is the property of the child object that 'links back' # to this object. linkback = options[:linkback] || "#{MetaUtils.expand(self)}_oid" meta :has, [klass, linkback] module_eval %{ def #{name}(extrasql = nil) Og.db.select_one("SELECT * FROM #{Backend.table(klass)} WHERE #{linkback}=\#\@oid \#\{extrasql\}", #{klass}) end def delete_#{name}(extrasql = nil) Og.db.exec("DELETE FROM #{Backend.table(klass)} WHERE #{linkback}=\#\@oid \#\{extrasql\}") end } end