File: alias_method.rb

package info (click to toggle)
ruby-backports 3.25.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,912 kB
  • sloc: ruby: 11,757; makefile: 6
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