lib/usable/mod_extender.rb in usable-3.3.0 vs lib/usable/mod_extender.rb in usable-3.4.0

- old
+ new

@@ -7,11 +7,11 @@ @mod = mod @options = options @options[:method] ||= :include @copy = mod @name = mod.name - @unwanted = options[:only] ? @copy.instance_methods - Array(options[:only]) : [] + @unwanted = find_unwanted_methods(options[:only]) if @unwanted.any? @copy = @copy.dup end end @@ -33,9 +33,18 @@ def mod_name if name name.split('::').last else "UsableMod#{Time.now.strftime('%s')}" + end + end + + def find_unwanted_methods(only) + return [] unless only + if :constants == only + @copy.instance_methods + else + @copy.instance_methods - Array(only) end end end end