File: public_send.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 (13 lines) | stat: -rw-r--r-- 474 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
unless Kernel.method_defined? :public_send
  module Kernel
    def public_send(method, *args, &block)
      if respond_to?(method) && !protected_methods.include?(method.to_s)
        send(method, *args, &block)
      else
        :foo.generate_a_no_method_error_in_preparation_for_method_missing rescue nil
        # otherwise a NameError might be raised when we call method_missing ourselves
        method_missing(method.to_sym, *args, &block)
      end
    end
  end
end