Module: Tins::Constant
- Included in:
- Module
- Defined in:
- lib/tins/dslkit.rb
Overview
This module contains the constant method. For small example of its usage see the documentation of the DSLAccessor module.
Instance Method Summary collapse
-
#constant(name, value = name) ⇒ Object
Create a constant named name, that refers to value value.
Instance Method Details
#constant(name, value = name) ⇒ Object
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.
162 163 164 165 |
# File 'lib/tins/dslkit.rb', line 162 def constant(name, value = name) value = value.freeze rescue value define_method(name) { value } end |