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

hibernate - How to load global settings frequently used in application in Java -

objective c - Ownership modifiers with manual reference counting -

python 3.x - Mapping specific letters onto a list of words -