Permalink
Browse files

putting hibernate! call on DataMapper.finalize method

  • Loading branch information...
1 parent 0d25fe3 commit 8afce901e5b51d010121b5545cffcd4a1e913bdb @douglasrodrigo douglasrodrigo committed Nov 10, 2011
@@ -49,4 +49,5 @@
require 'dm-hibernate-adapter/hibernate/transaction'
require 'dm-hibernate-adapter/hibernate/model'
require 'dm-hibernate-adapter/data_mapper/adapters/hibernate_adapter'
+require 'dm-hibernate-adapter/data_mapper/dm-core'
@@ -0,0 +1,10 @@
+module DataMapper
+ def self.finalize
+ Model.descendants.each do |model|
+ finalize_model(model)
+ model.hibernate!
+ end
+ self
+ end
+
+end
@@ -27,19 +27,7 @@ module Hibernate::Model
}
def self.included(model)
-
model.extend(ClassMethods)
-
- unless Hibernate.mapped?(model)
- [:auto_migrate!, :auto_upgrade!, :create, :all, :copy, :first, :first_or_create, :first_or_new, :get, :last, :load, :new].each do |method|
- model.before_class_method(method, :hibernate!)
- end
-
- [:save, :update, :destroy, :update_attributes].each do |method|
- model.before(method) { model.hibernate! }
- end
- end
-
end
module ClassMethods

0 comments on commit 8afce90

Please sign in to comment.