Skip to content

Commit

Permalink
Update #finalize to always return self
Browse files Browse the repository at this point in the history
* 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
dkubb committed Oct 29, 2011
1 parent 3a2a331 commit 27b5b04
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/dm-core.rb
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/dm-core/associations/many_to_many.rb
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/dm-core/associations/many_to_one.rb
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/dm-core/associations/one_to_many.rb
Expand Up @@ -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|
Expand All @@ -114,6 +116,7 @@ def finalize
end
end
inverse.finalize
self
end

# @api semipublic
Expand Down
3 changes: 2 additions & 1 deletion lib/dm-core/model.rb
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 27b5b04

Please sign in to comment.