Permalink
Browse files

Created a single point of definition for determination to whether or …

…not unextend a certain module
  • Loading branch information...
1 parent a729826 commit 395b108c71961731d5dba74a97b1c1c6dcbf46ae Paul Engel committed May 2, 2011
Showing with 9 additions and 3 deletions.
  1. +3 −1 CHANGELOG.rdoc
  2. +6 −2 lib/unextendable/object.rb
View
@@ -1,8 +1,10 @@
= Unextendable CHANGELOG
-== Version 0.1.2 (May xx, 2011)
+== Version 0.1.2 (May 2, 2011)
* Improved object_instance.unextend
+* Created a single point of definition for determination to whether or not unextend a certain module
+*
== Version 0.1.1 (May 1, 2011)
@@ -29,17 +29,21 @@ def extend(*modules)
def unextend(*modules, &block)
if modules.empty?
meta_class.extended_modules.delete_if do |mod|
- mod.unextendable? && (!block_given? || block.call(mod))
+ unextend? mod, &block
end
else
modules.each do |mod|
- meta_class.extended_modules.delete mod if mod.unextendable? && (!block_given? || block.call(mod))
+ meta_class.extended_modules.delete mod if unextend? mod, &block
end
end
end
private
+ def unextend?(mod, &block)
+ mod.unextendable? && (!block_given? || !!block.call(mod))
+ end
+
def wrap_unextendable_module(mod)
return unless (mod.class == Module) && mod.unextendable?

0 comments on commit 395b108

Please sign in to comment.