Module: ImmutableStructEx::Immutable

Defined in:
lib/immutable_struct_ex/immutable.rb

Overview

Makes a struct immutable when extended.

Class Method Summary collapse

Class Method Details

.extended(struct) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/immutable_struct_ex/immutable.rb', line 7

def extended(struct)
  [:[], *struct.members].each do |method|
    struct.instance_eval do
      undef :"#{method}="
    end
  end
end