Module: ImmutableRecord

Defined in:
lib/immutable_record.rb,
lib/immutable_record/version.rb

Defined Under Namespace

Classes: Value

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.new(*attributes) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/immutable_record.rb', line 4

def self.new (*attributes)
  unless attributes.all? { |attr| attr.is_a?(Symbol) }
    raise ArgumentError, "attributes should be symbols!"
  end

  Class.new(Value) do
    attr_reader(*attributes)
    const_set("ATTRIBUTES", attributes.dup.freeze)
  end
end