Server : Apache System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64 User : vapecompany ( 2719) PHP Version : 7.4.33 Disable Function : NONE Directory : /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