Sha256: 13dd0d0b874e92898c906e4a22da59c09acaa2dd4c54abf7a7ec87416c4e5f20
Contents?: true
Size: 517 Bytes
Versions: 1
Compression:
Stored size: 517 Bytes
Contents
class Value def self.new(*fields) value_class = Class.new value_class.instance_eval do attr_reader *fields define_method(:initialize) do |*input_fields| raise ArgumentError.new("wrong number of arguments, #{input_fields.size} for #{fields.size}") if fields.size != input_fields.size fields.each_with_index do |field, index| instance_variable_set('@' + field.to_s, input_fields[index]) end self.freeze end end return value_class end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
values-1.0.0 | lib/values.rb |