lib/facet/module/alias_module_function.rb in facets-0.9.0 vs lib/facet/module/alias_module_function.rb in facets-1.0.0
- old
+ new
@@ -1,56 +1,112 @@
-require 'nano/module/alias_module_function.rb'
\ No newline at end of file
+class Module
+
+ private
+ # Alias a module function so that the alias is also
+ # a module function. The typical #alias_method
+ # does not do this.
+ #
+ # module Demo
+ # module_function
+ # def hello
+ # "Hello"
+ # end
+ # end
+ #
+ # Demo.hello #=> Hello
+ #
+ # module Demo
+ # alias_module_function( :hi , :hello )
+ # end
+ #
+ # Demo.hi #=> Hello
+ #
+ def alias_module_function( new, old )
+ alias_method( new, old )
+ module_function( new )
+ end
+
+end
+
+
+# _____ _
+# |_ _|__ ___| |_
+# | |/ _ \/ __| __|
+# | | __/\__ \ |_
+# |_|\___||___/\__|
+#
+=begin test
+
+ require 'test/unit'
+
+ class TCModule < Test::Unit::TestCase
+
+ module MockModule
+ # for alias_module_method
+ def x ; 33 ; end
+ module_function :x
+ alias_module_function :y, :x
+ end
+
+ def test_alias_module_function
+ assert_equal( 33, MockModule.y )
+ #assert_equal( 33, @m.send(:y) ) # use send b/c private
+ end
+
+ end
+
+=end