method
    
    define_singleton_method
  
      v1_9_2_180 - 
      Show latest stable
 - 
    0 notes - 
    Class: Object
    
  
  
- 1_8_6_287
 - 1_8_7_72
 - 1_8_7_330
 - 1_9_1_378 (0)
 - 1_9_2_180 (38)
 - 1_9_3_125 (0)
 - 1_9_3_392 (0)
 - 2_1_10 (0)
 - 2_2_9 (0)
 - 2_4_6 (0)
 - 2_5_5 (0)
 - 2_6_3 (0)
 - What's this?
 
define_singleton_method(*args)
  public
  Defines a singleton method in the receiver. The method parameter can be a Proc, a Method or an UnboundMethod object. If a block is specified, it is used as the method body.
class A class << self def class_name to_s end end end A.define_singleton_method(:who_am_i) do "I am: #{class_name}" end A.who_am_i # ==> "I am: A" guy = "Bob" guy.define_singleton_method(:hello) { "#{self}: Hello there!" } guy.hello #=> "Bob: Hello there!"

  
  
  
  