method

class_variable_set

v2_2_9 - Show latest stable - Class: Module
class_variable_set(p1, p2)
public

Sets the class variable named by symbol to the given object. If the class variable name is passed as a string, that string is converted to a symbol.

class Fred
  @@foo = 99
  def foo
    @@foo
  end
end
Fred.class_variable_set(:@@foo, 101)     #=> 101
Fred.new.foo                             #=> 101