class Plan9::ImmutableStruct

@!visibility private

Protected Class Methods

init_new(struct) click to toggle source

Re-organized slightly, this code is reused from ‘ImmutableStruct’ by Theo Hultberg. See github.com/iconara/immutable_struct Copyright notice mentioned in the LICENSE file.

Calls superclass method Plan9::ImprovedStruct::init_new
# File lib/plan9/structures.rb, line 60
def self.init_new(struct)
  make_immutable!(struct)
  super(struct)
end

Private Class Methods

make_immutable!(struct) click to toggle source
# File lib/plan9/structures.rb, line 67
def self.make_immutable!(struct)
  # removes the member= method, to prevent write
  struct.send(:undef_method, "[]=".to_sym)
  struct.members.each do |member|
    struct.send(:undef_method, "#{member}=".to_sym)
  end
end