# Ruby: Immutable Value Object with Struct Freezing the initializer after passing the args to `super` makes the object immutable. ```rb # frozen_string_literal: true # Freezing the initializer after passing the args to `super` makes the object immutable. # # Example: # # require 'value_object' # # ForcePullData = Struct.new(:repository_name, :site_id, keyword_init: true) do # include ValueObject # end # # data = ForcePullData.new(repository_name: 'sandbox', site_id: 'site-id') # # > data.repository_name # => "sandbox" # # > data.repository_name = "plaything" # FrozenError: can't modify frozen ForcePullData: # # module ValueObject def initialize(**args) super(args) freeze end end ``` This trick comes from [Polished Ruby Programming](https://www.amazon.com/Polished-Ruby-Programming-maintainable-high-performance-ebook/dp/B093TH9P7C) by [Jeremy Evans](https://github.com/jeremyevans).