Created
April 24, 2016 23:50
-
-
Save jah2488/f04e1691e3cf8d3ee13cc0e66741e596 to your computer and use it in GitHub Desktop.
I feel like there is a whole blog post in here.
This file contains 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 Test | |
def initialize | |
puts "I've been created" | |
end | |
end | |
module Foo | |
def self.check | |
tester | |
end | |
def self.tester | |
@tester ||= Test.new | |
end | |
def self.reset | |
@tester = nil # Will 'empty' the ivar, but not actually 'remove' it from the object. | |
end | |
end | |
Foo.instance_variables #=> [] | |
Foo.check | |
Foo.instance_variables #=> [:@tester] | |
Foo.reset | |
Foo.instance_variables #=> [:@tester] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment