protobuf 3.8.4 → 3.8.5.pre0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/protobuf/enum.rb +19 -0
- data/lib/protobuf/version.rb +1 -1
- data/spec/lib/protobuf/enum_spec.rb +14 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36aed181d6bcd717ec7f3225b5aa6863b885834e928fb884fa078dc4227623e7
|
4
|
+
data.tar.gz: 9ec49612c7de625f50acaba9edcd3d912f5e81ba413d895f8176b1f1f98e6258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4851081c3d661dbb4fcdff2bd65435024297b83613dc55ac18f512ad5f25d25d449abdb07f2f2c15213d5b9250cd8c77c3143888c9fecc6540af95d5597fa369
|
7
|
+
data.tar.gz: 529044b03838d84adfb4cbe10935dea8da89f8f56968a2f117d87f58ff24964dfb548b576a77593ebe0f3dd48b3b4c7197903e9f4da4281c521a70be70f3700d
|
data/lib/protobuf/enum.rb
CHANGED
@@ -271,6 +271,25 @@ module Protobuf
|
|
271
271
|
tag.class
|
272
272
|
end
|
273
273
|
|
274
|
+
# Protobuf::Enum delegates methods to Fixnum, which has a custom hash equality method (`eql?`)
|
275
|
+
# This causes enum values to be equivalent when using `==`, `===`, `equals?`, but not `eql?`**:
|
276
|
+
#
|
277
|
+
# 2.3.7 :002 > ::Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO)
|
278
|
+
# => false
|
279
|
+
#
|
280
|
+
# However, they are equilvalent to their tag value:
|
281
|
+
#
|
282
|
+
# 2.3.7 :002 > ::Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO.tag)
|
283
|
+
# => true
|
284
|
+
#
|
285
|
+
# **The implementation changed in Ruby 2.5, so this only affects Ruby versions less than v2.4.
|
286
|
+
#
|
287
|
+
# Use the hash equality implementation from Object#eql?, which is equivalent to == instead.
|
288
|
+
#
|
289
|
+
def eql?(other)
|
290
|
+
self == other
|
291
|
+
end
|
292
|
+
|
274
293
|
def inspect
|
275
294
|
"\#<Protobuf::Enum(#{parent_class})::#{name}=#{tag}>"
|
276
295
|
end
|
data/lib/protobuf/version.rb
CHANGED
@@ -268,6 +268,20 @@ RSpec.describe Protobuf::Enum do
|
|
268
268
|
specify { subject.try { |yielded| expect(yielded).to eq(subject) } }
|
269
269
|
end
|
270
270
|
|
271
|
+
describe '#eql?' do
|
272
|
+
it "is equal to itself" do
|
273
|
+
expect(::Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO)).to be(true)
|
274
|
+
end
|
275
|
+
|
276
|
+
it "is equal to it's tag" do
|
277
|
+
expect(::Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO.tag)).to be(true)
|
278
|
+
end
|
279
|
+
|
280
|
+
it "is not equal to it's name" do
|
281
|
+
expect(::Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO.name)).to be(false)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
271
285
|
context 'when coercing from enum' do
|
272
286
|
subject { Test::StatusType::PENDING }
|
273
287
|
it { is_expected.to eq(0) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.8.
|
4
|
+
version: 3.8.5.pre0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BJ Neilsen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -463,9 +463,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
463
463
|
version: '0'
|
464
464
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
465
465
|
requirements:
|
466
|
-
- - "
|
466
|
+
- - ">"
|
467
467
|
- !ruby/object:Gem::Version
|
468
|
-
version:
|
468
|
+
version: 1.3.1
|
469
469
|
requirements: []
|
470
470
|
rubyforge_project:
|
471
471
|
rubygems_version: 2.7.6
|