Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created April 30, 2016 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b7ead5891d9a7f834bd3ce7b165ff2a9 to your computer and use it in GitHub Desktop.
Save anonymous/b7ead5891d9a7f834bd3ce7b165ff2a9 to your computer and use it in GitHub Desktop.
class A
def initialize(owner)
@owner = owner
end
def owner_name
@owner.class.name.split("::").last
end
def do_stuff
puts owner_name
end
end
class B
def initialize
@a = A.new(self)
end
def do_stuff
@a.do_stuff
end
end
b = B.new
b.do_stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment