Sharing variables between Ruby classes within same module -
Sharing variables between Ruby classes within same module -
i have module
# file 1.rb module search class attr_accessor :results def find_results self.results = [somethings] end def do_something_with_results b = b.new.do_something b.response #=> c = c.new.use_b_response_do_something homecoming c.did_something end end end # file 2.rb module search class b end class c end end
i have module search
classes a, b, c
class , brings info needs shared classes b , c info (refine it, send somewhere, homecoming true or false).
how can share info between classes? have been doing think wrong
def do_something b = b.new.doing_something c = c.new.something_else(b.some_attr) end
which not efficient
i don't see issues in code. seem doing things should done. using methods , pass info around.
one thing create code improve passing b c instead.
def do_something b = b.new.doing_something c = c.new(b).something_else end
but depends on utilize case...
ruby
Comments
Post a Comment