diff --git a/lib/dm-core/model.rb b/lib/dm-core/model.rb index 1d24712c..cf40f745 100644 --- a/lib/dm-core/model.rb +++ b/lib/dm-core/model.rb @@ -36,7 +36,7 @@ def self.default_storage_name RUBY end - model.instance_eval(&block) if block_given? + model.instance_eval(&block) if block model end @@ -302,7 +302,7 @@ def first_or_create(conditions = {}, attributes = {}) # the newly initialized Resource instance # # @api public - def new(attributes = {}) + def new(attributes = {}, &block) assert_valid model = if discriminator = properties(repository_name).discriminator @@ -312,7 +312,7 @@ def new(attributes = {}) model ||= self resource = model.allocate - resource.send(:initialize, attributes) + resource.send(:initialize, attributes, &block) resource end