Sha256: f3cf469dbb692cf4ac00e6384cc199412f87a4b568770e3735e0b8379caa883a

Contents?: true

Size: 1000 Bytes

Versions: 26

Compression:

Stored size: 1000 Bytes

Contents

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
facets-0.9.0 lib/nano/module/alias_module_function.rb
facets-1.0.0 lib/facet/module/alias_module_function.rb
facets-1.0.3 packages/core/lib/facet/module/alias_module_function.rb
facets-1.3.0 lib/facets/core/module/alias_module_function.rb
facets-1.2.0 lib/facets/core/module/alias_module_function.rb
facets-1.1.0 lib/facet/module/alias_module_function.rb
facets-1.2.1 lib/facets/core/module/alias_module_function.rb
facets-1.3.1 lib/facets/core/module/alias_module_function.rb
facets-1.3.2 lib/facets/core/module/alias_module_function.rb
facets-1.3.3 lib/facets/core/module/alias_module_function.rb
facets-1.4.0 lib/facets/core/module/alias_module_function.rb
facets-1.4.1 lib/facets/core/module/alias_module_function.rb
facets-1.4.2 lib/facets/core/module/alias_module_function.rb
facets-1.4.3 lib/facets/core/module/alias_module_function.rb
facets-1.4.4 lib/facets/core/module/alias_module_function.rb
facets-1.4.5 lib/facets/core/module/alias_module_function.rb
facets-1.7.0 lib/facets/core/module/alias_module_function.rb
facets-1.7.30 lib/facets/core/module/alias_module_function.rb
facets-1.7.38 lib/facets/core/module/alias_module_function.rb
facets-1.7.46 lib/facets/core/module/alias_module_function.rb