module Tins::Constant

This module contains the constant method. For small example of its usage see the documentation of the DSLAccessor module.

Public Instance Methods

constant(name, value = name) click to toggle source

Create a constant named name, that refers to value value. _value is frozen, if this is possible. If you want to modify/exchange a value use DSLAccessor#dsl_reader/DSLAccessor#dsl_accessor instead.

# File lib/tins/dslkit.rb, line 199
def constant(name, value = name)
  value = value.freeze rescue value
  define_method(name) { value }
end