Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sei0o
Created March 6, 2014 00:38
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 sei0o/9379879 to your computer and use it in GitHub Desktop.
Save sei0o/9379879 to your computer and use it in GitHub Desktop.
外部のmoduleから別のmoduleのクラス変数にアクセス(定数じゃなくて) | module間で変数を共有
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