Skip to content
ed-mare edited this page Feb 1, 2019 · 3 revisions

Redefine Constant

Get rid of the tiresome constant warnings. From https://stackoverflow.com/questions/3375360/how-to-redefine-a-ruby-constant-without-warning#3377188

module Constants

  def self.define(const, value)
    self.class.const_set(const, value) unless self.class.const_defined?(const)
  end

  def self.redefine(const, value)
    self.class.send(:remove_const, const) if self.class.const_defined?(const)
    self.class.const_set(const, value)
  end

end

Rake

Clone this wiki locally