Is it okay to assign an instantiated class to a class variable in Ruby? -
is okay instantiate class , assign class variable in class b call a's methods in b?
class ... end class b @@a = a.new def method_b @@a.method_a end end
you can wrap methods in module , include
them in class(for instance methods only)
module foo def method_a p 'hello' end end class b include foo def method_b method_a end end b.new.method_b
Comments
Post a Comment