Created
March 6, 2014 00:38
-
-
Save sei0o/9379879 to your computer and use it in GitHub Desktop.
外部のmoduleから別のmoduleのクラス変数にアクセス(定数じゃなくて) | module間で変数を共有
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
module A | |
@@hoge = 300 | |
end | |
module B # Aのクラス変数をGet | |
piyo = A.module_eval { class_variable_get :@@hoge } | |
p piyo # => 300 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment