Skip to content
Browse files

Update #finalize to always return self

* In general command methods like finalize will return self, as the DM API
  moves closer towards using CQS like Veritas, Virtus and other libraries
  that will be part of DM2.
  • Loading branch information...
1 parent 3a2a331 commit 27b5b044c0dbc70d87667adb5d86ce0e26cc009d @dkubb dkubb committed Oct 28, 2011
View
2 lib/dm-core.rb
@@ -280,7 +280,7 @@ def self.repository(name = nil)
# These are otherwise lazily declared, which can lead to unexpected errors.
# It also performs basic validity checking of the DataMapper models.
#
- # @return [DataMapper] The DataMapper module
+ # @return [self]
#
# @api public
def self.finalize
View
3 lib/dm-core/associations/many_to_many.rb
@@ -126,10 +126,13 @@ def links
# Initialize the chain for "many to many" relationships
#
+ # @return [self]
+ #
# @api public
def finalize
through
via
+ self
end
# @api private
View
3 lib/dm-core/associations/many_to_one.rb
@@ -72,9 +72,12 @@ def child_key
# Initialize the foreign key property this "many to one"
# relationship uses to persist itself
#
+ # @return [self]
+ #
# @api public
def finalize
child_key
+ self
end
# Returns a hash of conditions that scopes query that fetches
View
3 lib/dm-core/associations/one_to_many.rb
@@ -104,6 +104,8 @@ def lazy_load(source)
# initializing other relationships. This makes sure that foreign key
# properties always appear in the order they were declared.
#
+ # @return [self]
+ #
# @api public
def finalize
child_model.relationships.each do |relationship|
@@ -114,6 +116,7 @@ def finalize
end
end
inverse.finalize
+ self
end
# @api semipublic
View
3 lib/dm-core/model.rb
@@ -130,7 +130,7 @@ def raise_on_save_failure=(raise_on_save_failure)
# Finish model setup and verify it is valid
#
- # @return [undefined]
+ # @return [self]
#
# @api public
def finalize
@@ -139,6 +139,7 @@ def finalize
assert_valid_name
assert_valid_properties
assert_valid_key
+ self
end
# Appends a module for inclusion into the model class after Resource.

0 comments on commit 27b5b04

Please sign in to comment.
Something went wrong with that request. Please try again.