Permalink
Browse files

[dm-constraints] added a method to wrap changed method visibility tasks

Signed-off-by: Balint Erdi <balint.erdi@gmail.com>
  • Loading branch information...
1 parent 7e0dcc4 commit 692cb39e40c2539cc45059a78a8bddbfab96acbf @balinterdi balinterdi committed with Dan Kubb Jan 15, 2009
Showing with 11 additions and 3 deletions.
  1. +3 −3 dm-constraints/lib/dm-constraints.rb
  2. +8 −0 dm-constraints/lib/dm-constraints/delete_constraint.rb
@@ -24,9 +24,9 @@ class Relationship
# initialize is a private method in Relationship
# and private methods can not be "advised" (hooked into)
# in extlib.
- public(:initialize)
- before :initialize, :add_delete_constraint_option
- private(:initialize)
+ with_changed_method_visibility(:initialize, :private, :public) do
+ before :initialize, :add_delete_constraint_option
+ end
end
end
end
@@ -16,6 +16,14 @@ def check_delete_constraint_type(cardinality, name, options = {})
raise ArgumentError, ":constraint option must be one of #{delete_constraint_options * ', '}"
end
end
+
+ # TODO: that should be moved to a 'util-like' module
+ def with_changed_method_visibility(method, from_visibility, to_visibility, &block)
+ send(to_visibility, method)
+ yield
+ send(from_visibility, method)
+ end
+
end
def add_delete_constraint_option(name, repository_name, child_model, parent_model, options = {})

0 comments on commit 692cb39

Please sign in to comment.