Module: Kernel
- Defined in:
- lib/as/backports/public_send.rb,
lib/as/backports/define_singleton_method.rb
Instance Method Summary collapse
Instance Method Details
#define_singleton_method(*args, &block) ⇒ Object
6 7 8 9 10 |
# File 'lib/as/backports/define_singleton_method.rb', line 6 def define_singleton_method(*args, &block) class << self self end.send(:define_method, *args, &block) end |
#public_send(method, *args, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/as/backports/public_send.rb', line 6 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 |