attr_set_once
This gem adds a attr_set_once to the Class class. Use attr_set_once like
attr_accessor.
class MyClass
attr_set_once :hsa
end
The attribute can be set as usual:
myob = MyClass.new
myob.hsa = 'x'
myob.hsa #=> x
However, once the attribute has been set, it cannot be set again.
myob.hsa = 'y' # raises 'set-once-instance-variable-already-set: hsa'
Install
gem install setonce
Author
Mike O'Sullivan [email protected]
History
| version | date | notes |
|---|---|---|
| 1.0 | Mar 2, 2020 | Initial upload. |