instance method
Module#class_variables
(?::boolish inherit) -> ::Array[::Symbol]
mod.class_variables(inherit=true) → array
object.c
View on GitHub ↗
VALUE
rb_mod_class_variables(int argc, const VALUE *argv, VALUE mod)
{
bool inherit = true;
st_table *tbl;
if (rb_check_arity(argc, 0, 1)) inherit = RTEST(argv[0]);
if (inherit) {
tbl = mod_cvar_of(mod, 0);
}
else {
tbl = mod_cvar_at(mod, 0);
}
return cvar_list(tbl);
}
Returns an array of the names of class variables in mod. This includes the names of class variables in any included modules, unless the inherit parameter is set to false.
Example
class One @@var1 = 1 end class Two < One @@var2 = 2 end One.class_variables #=> [:@@var1] Two.class_variables #=> [:@@var2, :@@var1] Two.class_variables(false) #=> [:@@var2]
See also
#class_variable_get
#class_variable_set
#class_variable_defined?
#const_added
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0