Skip to content

Instantly share code, notes, and snippets.

@davetron5000
Created April 7, 2021 14:50
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 davetron5000/5bd5f69d6ced4063d2f9ee83ed8ab262 to your computer and use it in GitHub Desktop.
Save davetron5000/5bd5f69d6ced4063d2f9ee83ed8ab262 to your computer and use it in GitHub Desktop.
class PublicClassPeopleUse
def initialize
# whatever
@real_instance = SetupOnly.new
end
def setup
after_setup_instance = @real_instance.setup
@real_instance = after_setup_instance
end
delegate_missing_to :@real_instance
class SetupOnly
def setup
# whatever
AfterSetup.new(whatever,stuff,initializes,state)
end
end
class AfterSetup
def initialize(private_stuff,can_be_whatever)
# ...
end
def method_called_only_after_setup
# ...
end
end
end
# i = PublicClassPeopleUse.new
# i.method_called_only_after_setup
# => No Method Error [ could customize this somehow ]
# i.setup
# i.method_called_only_after_setup
# => WORKS!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment