Skip to content

Commit

Permalink
Add some private Model instance methods to some some plugins easier
Browse files Browse the repository at this point in the history
This adds _delete, _delete_dataset, and _update_dataset private
methods, allowing more granularity when overriding in plugins.
  • Loading branch information
jeremyevans committed Apr 9, 2010
1 parent d6ea38e commit 684232e
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/sequel/model/base.rb
Expand Up @@ -604,7 +604,7 @@ def changed_columns
# Deletes and returns self. Does not run destroy hooks.
# Look into using destroy instead.
def delete
this.delete
_delete
self
end

Expand Down Expand Up @@ -819,6 +819,17 @@ def valid?
end

private

# Actually do the deletion of the object's dataset.
def _delete
_delete_dataset.delete
end

# The dataset to use when deleting the object. The same as the object's
# dataset by default.
def _delete_dataset
this
end

# Internal destroy method, separted from destroy to
# allow running inside a transaction
Expand Down Expand Up @@ -901,7 +912,13 @@ def _save(columns, opts)

# Update this instance's dataset with the supplied column hash.
def _update(columns)
this.update(columns)
_update_dataset.update(columns)
end

# The dataset to use when updating an object. The same as the object's
# dataset by default.
def _update_dataset
this
end

# If raise_on_save_failure is false, check for BeforeHookFailed
Expand Down

0 comments on commit 684232e

Please sign in to comment.