| Server IP : 162.214.74.102 / Your IP : 216.73.217.46 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/opt/cpanel/ea-ruby24/root/usr/share/ri/system/Module/ |
Upload File : |
U:RDoc::AnyMethod[iI"define_method:ETI"Module#define_method;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I">Defines an instance method in the receiver. The _method_ ;TI"Iparameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object. ;TI"HIf a block is specified, it is used as the method body. This block ;TI"Dis evaluated using <code>instance_eval</code>, a point that is ;TI"Jtricky to demonstrate because <code>define_method</code> is private. ;TI"@(This is why we resort to the +send+ hack in this example.);To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"
class A
;TI" def fred
;TI" puts "In Fred"
;TI" end
;TI"' def create_method(name, &block)
;TI"7 self.class.send(:define_method, name, &block)
;TI" end
;TI"3 define_method(:wilma) { puts "Charge it!" }
;TI" end
;TI"class B < A
;TI"6 define_method(:barney, instance_method(:fred))
;TI" end
;TI"a = B.new
;TI"a.barney
;TI"
a.wilma
;TI"(a.create_method(:betty) { p self }
;TI"
a.betty
;T:@format0o;
; [I"<em>produces:</em>;T@o;; [I"
In Fred
;TI"Charge it!
;TI"#<B:0x401b39e8>;T;
0:
@fileI"proc.c;T:0@omit_headings_from_table_of_contents_below0I"]define_method(symbol, method) -> symbol
define_method(symbol) { block } -> symbol
;T0[ I"(*args);T@/FI"Module;TcRDoc::NormalClass00