How to create an instance with part of the methods of a class in Ruby? -


i have class methods x , y. want create instance want have method x class a.

how should it? should deleting method y instance when creating it? appreciated!

you should not this. should instead share problem you're solving , find better pattern solving it.


an example solving problem little differently:

class   def x; end end  module foo   def y; end end  instance_with_y = a.new instance_with_y.send :include, foo instance_with_y.respond_to? :y #=> true 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -