Created
April 7, 2021 14:50
-
-
Save davetron5000/5bd5f69d6ced4063d2f9ee83ed8ab262 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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