Method: Functional::FinalStruct#set
- Defined in:
- lib/functional/final_struct.rb
#set(field, value) ⇒ Object Also known as: []=
Set the value of the give field to the given value.
It is a logical error to attempt to set a final field more than once, as this violates the concept of finality. Calling the method a second or subsequent time for a given field will result in an exception being raised.
90 91 92 93 94 95 96 97 98 |
# File 'lib/functional/final_struct.rb', line 90 def set(field, value) synchronize do if ns_attribute_has_been_set?(field) raise FinalityError.new("final accessor '#{field}' has already been set") else ns_set_attribute(field, value) end end end |