File: alias_method.rb

package info (click to toggle)
ruby-backports 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,460 kB
  • ctags: 703
  • sloc: ruby: 6,195; makefile: 24
file content (8 lines) | stat: -rw-r--r-- 302 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
module Backports
  # Safe alias_method that will only alias if the source exists and destination doesn't
  def self.alias_method(mod, new_name, old_name)
    mod.instance_eval do
      alias_method new_name, old_name
    end if mod.method_defined?(old_name) && !mod.method_defined?(new_name)
  end
end