Sha256: 7bf6f18993634df350bc204800f25d6995f7e3e4819995020078ad2bf4f20266

Contents?: true

Size: 406 Bytes

Versions: 10

Compression:

Stored size: 406 Bytes

Contents

class Module

  private

  # Aliases a method and undefines the original.
  #
  #   rename_method( :to_method, :from_method  )
  #
  # CREDIT: Trans

  def rename_method( to_sym, from_sym )
    raise ArgumentError, "method #{from_sym} does not exist" unless method_defined?( from_sym )
    alias_method( to_sym, from_sym )
    undef_method( from_sym )
  end

  alias_method :rename,   :rename_method

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/module/rename_method.rb
facets-2.8.3 lib/core/facets/module/rename_method.rb
facets-2.8.2 lib/core/facets/module/rename_method.rb
facets-2.8.1 lib/core/facets/module/rename_method.rb
facets-2.8.0 lib/core/facets/module/rename_method.rb
facets-2.7.0 lib/core/facets/module/rename_method.rb
facets-2.6.0 lib/core/facets/module/rename_method.rb
facets-2.5.1 lib/core/facets/module/rename_method.rb
facets-2.5.0 lib/core/facets/module/rename_method.rb
facets-2.5.2 lib/core/facets/module/rename_method.rb