Server IP : 66.29.132.122 / Your IP : 18.119.122.106 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/alt/ruby18/share/ri/1.8/system/Module/ |
Upload File : |
--- !ruby/object:RI::MethodDescription aliases: [] block_params: comment: - !ruby/struct:SM::Flow::P body: Defines an instance method in the receiver. The <em>method</em> parameter can be a <tt>Proc</tt> or <tt>Method</tt> object. If a block is specified, it is used as the method body. This block is evaluated using <tt>instance_eval</tt>, a point that is tricky to demonstrate because <tt>define_method</tt> is private. (This is why we resort to the <tt>send</tt> hack in this example.) - !ruby/struct:SM::Flow::VERB body: " class A\n def fred\n puts "In Fred"\n end\n def create_method(name, &block)\n self.class.send(:define_method, name, &block)\n end\n define_method(:wilma) { puts "Charge it!" }\n end\n class B < A\n define_method(:barney, instance_method(:fred))\n end\n a = B.new\n a.barney\n a.wilma\n a.create_method(:betty) { p self }\n a.betty\n" - !ruby/struct:SM::Flow::P body: <em>produces:</em> - !ruby/struct:SM::Flow::VERB body: " In Fred\n Charge it!\n #<B:0x401b39e8>\n" full_name: Module#define_method is_singleton: false name: define_method params: | define_method(symbol, method) => new_method define_method(symbol) { block } => proc visibility: public