values 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -0
- data/VERSION +1 -1
- data/lib/values.rb +5 -3
- data/values.gemspec +1 -1
- metadata +3 -3
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/lib/values.rb
CHANGED
@@ -2,16 +2,18 @@ class Value
|
|
2
2
|
def self.new(*fields)
|
3
3
|
return Class.new do
|
4
4
|
attr_reader *fields
|
5
|
+
|
5
6
|
define_method(:initialize) do |*input_fields|
|
6
7
|
raise ArgumentError.new("wrong number of arguments, #{input_fields.size} for #{fields.size}") if fields.size != input_fields.size
|
7
8
|
|
8
9
|
fields.each_with_index do |field, index|
|
9
10
|
instance_variable_set('@' + field.to_s, input_fields[index])
|
10
11
|
end
|
11
|
-
@__fields = fields
|
12
12
|
self.freeze
|
13
13
|
end
|
14
14
|
|
15
|
+
const_set :VALUE_ATTRS, fields
|
16
|
+
|
15
17
|
def ==(other)
|
16
18
|
self.eql?(other)
|
17
19
|
end
|
@@ -19,7 +21,7 @@ class Value
|
|
19
21
|
def eql?(other)
|
20
22
|
return false if other.class != self.class
|
21
23
|
result = true
|
22
|
-
|
24
|
+
self.class::VALUE_ATTRS.each do |field|
|
23
25
|
result = result && self.send(field) == other.send(field)
|
24
26
|
end
|
25
27
|
return result
|
@@ -27,7 +29,7 @@ class Value
|
|
27
29
|
|
28
30
|
def hash
|
29
31
|
result = 0
|
30
|
-
|
32
|
+
self.class::VALUE_ATTRS.each do |field|
|
31
33
|
result += field.hash
|
32
34
|
end
|
33
35
|
return result + self.class.hash
|
data/values.gemspec
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 1.
|
9
|
+
version: 1.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Tom Crayford
|
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
111
|
requirements:
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
hash:
|
114
|
+
hash: -2915973544868875541
|
115
115
|
segments:
|
116
116
|
- 0
|
117
117
|
version: "0"
|