lib/og/connection.rb in og-0.8.0 vs lib/og/connection.rb in og-0.9.3
- old
+ new
@@ -1,41 +1,42 @@
-# code:
-# * George Moschovitis <gm@navel.gr>
-#
-# (c) 2004 Navel, all rights reserved.
-# $Id: connection.rb 167 2004-11-23 14:03:10Z gmosx $
+#--
+# George Moschovitis <gm@navel.gr>
+# (c) 2004-2005 Navel, all rights reserved.
+# $Id: connection.rb 248 2005-01-31 13:38:34Z gmosx $
+#++
class Og;
-require "glue/property"
-require "glue/array"
-require "glue/time"
+require 'glue/property'
+require 'glue/array'
+require 'glue/time'
-# = Connection
-#
# A Connection to the Database. This file defines the skeleton
# functionality. A backend specific implementation file (driver)
# implements all methods.
#
# === Future
#
# - support caching.
# - support prepared statements.
-#
+
class Connection
# The frontend (Og) contains useful strucutres.
+
attr_reader :og
# The backend
+
attr_reader :db
# If set to true, the select methods deserialize the
# resultset to create entities.
+
attr_accessor :deserialize
# Initialize a connection to the database
- #
+
def initialize(og)
@og = og
@db = @og.config[:backend].new(@og.config)
@deserialize = true
Logger.debug "Created DB connection." if $DBG
@@ -187,12 +188,11 @@
end
# TODO: implement this as stored procedure? naaah.
transaction do |tx|
tx.exec "DELETE FROM #{klass::DBTABLE} WHERE oid=#{oid}"
-
- if cascade and klass.respond_to?(:og_descendants)
- klass.og_descendants.each do |dclass, linkback|
+ if cascade and klass.__meta.include?(:has)
+ klass.__meta[:has].each do |dclass, linkback|
tx.exec "DELETE FROM #{dclass::DBTABLE} WHERE #{linkback}=#{oid}"
end
end
end
end