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

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -