Created
December 5, 2013 10:59
-
-
Save shahoxo/7803518 to your computer and use it in GitHub Desktop.
インスタンス変数と同じライフサイクルのクラスインスタンス変数をつくる
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 Hoge | |
def initialize | |
@initialized_at = self.class.hoge | |
end | |
def self.hoge | |
@hoge = nil if ObjectSpace.each_object(Hoge).none? | |
@hoge ||= Time.now | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment