Class: Mores::ImmutableStruct

Inherits:
Struct
  • Object
show all
Defined in:
lib/mores/immutable_struct.rb

Defined Under Namespace

Modules: Flyweight, Strict

Class Method Summary collapse

Class Method Details

.new(*args, flyweight: true, strict: false, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/mores/immutable_struct.rb', line 11

def self.new(*args, flyweight: true, strict: false, &block)
  super(*args, &block).tap do |klass|
    klass.instance_eval do
      members.each { |x| remove_method "#{x}=" }
      include Flyweight if flyweight
      include Strict if strict
    end
  end
end