From 63b383e8606413a2768dcaee2d54fb35dd889ade Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 7 Jul 2026 15:07:38 -0600 Subject: [PATCH 1/8] RUBY-3814 Remove unused IllegalKey error class and ILLEGAL_KEY constant --- lib/bson/error/illegal_key.rb | 23 ----------------------- lib/bson/string.rb | 5 ----- 2 files changed, 28 deletions(-) delete mode 100644 lib/bson/error/illegal_key.rb diff --git a/lib/bson/error/illegal_key.rb b/lib/bson/error/illegal_key.rb deleted file mode 100644 index b56d82390..000000000 --- a/lib/bson/error/illegal_key.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true -# rubocop:todo all - -module BSON - class Error - - # Raised when validating keys and a key is illegal in MongoDB - class IllegalKey < Error - - # Instantiate the exception. - # - # @example Instantiate the exception. - # BSON::Error::IllegalKey.new(string) - # - # @param [ String ] string The illegal string. - # - # @api private - def initialize(string) - super("'#{string}' is an illegal key in MongoDB. Keys may not start with '$' or contain a '.'.") - end - end - end -end diff --git a/lib/bson/string.rb b/lib/bson/string.rb index 7d91487a5..419bd274b 100644 --- a/lib/bson/string.rb +++ b/lib/bson/string.rb @@ -30,11 +30,6 @@ module String # @since 2.0.0 BSON_TYPE = ::String.new(2.chr, encoding: BINARY).freeze - # Regex for matching illegal BSON keys. - # - # @since 4.1.0 - ILLEGAL_KEY = /(\A[$])|(\.)/ - # Get the string as encoded BSON. # # @example Get the string as encoded BSON. From 84de9efb98fa1dd9e8e63f3ff164794e5b763516 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 7 Jul 2026 15:25:39 -0600 Subject: [PATCH 2/8] deprecate PACK constants (were only used in tests) --- lib/bson/float.rb | 3 +++ lib/bson/int32.rb | 8 +++----- lib/bson/int64.rb | 3 +++ spec/bson/byte_buffer_write_spec.rb | 28 ++++++++++++++-------------- spec/bson/date_spec.rb | 4 ++-- spec/bson/date_time_spec.rb | 4 ++-- spec/bson/decimal128_spec.rb | 2 +- spec/bson/float_spec.rb | 2 +- spec/bson/int32_spec.rb | 8 ++++---- spec/bson/int64_spec.rb | 4 ++-- spec/bson/integer_spec.rb | 4 ++-- spec/bson/time_spec.rb | 6 +++--- spec/bson/time_with_zone_spec.rb | 4 ++-- spec/bson/timestamp_spec.rb | 2 +- spec/support/pack_directives.rb | 18 ++++++++++++++++++ 15 files changed, 61 insertions(+), 39 deletions(-) create mode 100644 spec/support/pack_directives.rb diff --git a/lib/bson/float.rb b/lib/bson/float.rb index eb9f448be..9da3088a9 100644 --- a/lib/bson/float.rb +++ b/lib/bson/float.rb @@ -32,7 +32,10 @@ module Float # The pack directive is for 8 byte floating points. # # @since 2.0.0 + # @deprecated No longer used internally; retained for backward + # compatibility and slated for removal in a future major version. PACK = "E" + deprecate_constant :PACK # Get the floating point as encoded BSON. # diff --git a/lib/bson/int32.rb b/lib/bson/int32.rb index da1ae1f4d..4f73fa8c3 100644 --- a/lib/bson/int32.rb +++ b/lib/bson/int32.rb @@ -29,15 +29,13 @@ class Int32 # @since 2.0.0 BSON_TYPE = ::String.new(16.chr, encoding: BINARY).freeze - # The number of bytes constant. - # - # @since 4.0.0 - BYTES_LENGTH = 4 - # Constant for the int 32 pack directive. # # @since 2.0.0 + # @deprecated No longer used internally; retained for backward + # compatibility and slated for removal in a future major version. PACK = "l<" + deprecate_constant :PACK # Deserialize an Integer from BSON. # diff --git a/lib/bson/int64.rb b/lib/bson/int64.rb index 2720d0198..b505efb1e 100644 --- a/lib/bson/int64.rb +++ b/lib/bson/int64.rb @@ -32,7 +32,10 @@ class Int64 # Constant for the int 64 pack directive. # # @since 2.0.0 + # @deprecated No longer used internally; retained for backward + # compatibility and slated for removal in a future major version. PACK = "q<" + deprecate_constant :PACK # Deserialize an Integer from BSON. # diff --git a/spec/bson/byte_buffer_write_spec.rb b/spec/bson/byte_buffer_write_spec.rb index f39126a5c..e40d54f5e 100644 --- a/spec/bson/byte_buffer_write_spec.rb +++ b/spec/bson/byte_buffer_write_spec.rb @@ -238,7 +238,7 @@ it 'appends the string to the byte buffer' do expect(modified.to_s).to eq( - "#{[ 4 ].pack(BSON::Int32::PACK)}#{(string.bytesize + 1).to_bson.to_s}#{string}#{BSON::NULL_BYTE}" + "#{[ 4 ].pack(PackDirectives::INT32)}#{(string.bytesize + 1).to_bson.to_s}#{string}#{BSON::NULL_BYTE}" ) end @@ -457,7 +457,7 @@ end it 'appends the double to the buffer' do - expect(modified.to_s).to eq([ 1.2332 ].pack(Float::PACK)) + expect(modified.to_s).to eq([ 1.2332 ].pack(PackDirectives::FLOAT)) end it 'increments the write position by 8' do @@ -471,7 +471,7 @@ end it 'writes a double' do - expect(modified.to_s).to eq([ 3 ].pack(Float::PACK)) + expect(modified.to_s).to eq([ 3 ].pack(PackDirectives::FLOAT)) end it 'increments the write position by 8' do @@ -525,7 +525,7 @@ end let(:expected) do - [ Integer::MAX_32BIT - 1 ].pack(BSON::Int32::PACK) + [ Integer::MAX_32BIT - 1 ].pack(PackDirectives::INT32) end it 'appends the int32 to the byte buffer' do @@ -544,7 +544,7 @@ end let(:expected) do - [ Integer::MIN_32BIT + 1 ].pack(BSON::Int32::PACK) + [ Integer::MIN_32BIT + 1 ].pack(PackDirectives::INT32) end it 'appends the int32 to the byte buffer' do @@ -573,7 +573,7 @@ end let(:expected) do - [ 4 ].pack(BSON::Int32::PACK) + [ 4 ].pack(PackDirectives::INT32) end it 'appends the int32 to the byte buffer' do @@ -627,7 +627,7 @@ end let(:expected) do - [ 4294967295 ].pack(BSON::Int32::PACK) + [ 4294967295 ].pack(PackDirectives::INT32) end it 'appends the int32 to the byte buffer' do @@ -693,7 +693,7 @@ end let(:expected) do - [ Integer::MAX_64BIT - 1 ].pack(BSON::Int64::PACK) + [ Integer::MAX_64BIT - 1 ].pack(PackDirectives::INT64) end it 'appends the int64 to the byte buffer' do @@ -712,7 +712,7 @@ end let(:expected) do - [ Integer::MIN_64BIT + 1 ].pack(BSON::Int64::PACK) + [ Integer::MIN_64BIT + 1 ].pack(PackDirectives::INT64) end it 'appends the int64 to the byte buffer' do @@ -751,7 +751,7 @@ end let(:expected) do - [ 4 ].pack(BSON::Int64::PACK) + [ 4 ].pack(PackDirectives::INT64) end it 'appends the int64 to the byte buffer' do @@ -767,19 +767,19 @@ describe '#replace_int32' do let(:exp_0) do - [ 0 ].pack(BSON::Int32::PACK) + [ 0 ].pack(PackDirectives::INT32) end let(:exp_first) do - [ 5 ].pack(BSON::Int32::PACK) + [ 5 ].pack(PackDirectives::INT32) end let(:exp_second) do - [ 4 ].pack(BSON::Int32::PACK) + [ 4 ].pack(PackDirectives::INT32) end let(:exp_42) do - [ 42 ].pack(BSON::Int32::PACK) + [ 42 ].pack(PackDirectives::INT32) end let(:modified) do diff --git a/spec/bson/date_spec.rb b/spec/bson/date_spec.rb index 833c589cd..31264152f 100644 --- a/spec/bson/date_spec.rb +++ b/spec/bson/date_spec.rb @@ -25,7 +25,7 @@ let(:obj) { Date.new(2012, 1, 1) } let(:time) { Time.utc(2012, 1, 1) } - let(:bson) { [ (time.to_f * 1000).to_i ].pack(BSON::Int64::PACK) } + let(:bson) { [ (time.to_f * 1000).to_i ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" end @@ -34,7 +34,7 @@ let(:obj) { Date.new(1969, 1, 1) } let(:time) { Time.utc(1969, 1, 1) } - let(:bson) { [ (time.to_f * 1000).to_i ].pack(BSON::Int64::PACK) } + let(:bson) { [ (time.to_f * 1000).to_i ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" end diff --git a/spec/bson/date_time_spec.rb b/spec/bson/date_time_spec.rb index b792d7402..c56889536 100644 --- a/spec/bson/date_time_spec.rb +++ b/spec/bson/date_time_spec.rb @@ -24,7 +24,7 @@ context "when the date time is post epoch" do let(:obj) { DateTime.new(2012, 1, 1, 0, 0, 0) } - let(:bson) { [ (obj.to_time.to_f * 1000).to_i ].pack(BSON::Int64::PACK) } + let(:bson) { [ (obj.to_time.to_f * 1000).to_i ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" end @@ -32,7 +32,7 @@ context "when the date time is pre epoch" do let(:obj) { DateTime.new(1969, 1, 1, 0, 0, 0) } - let(:bson) { [ (obj.to_time.to_f * 1000).to_i ].pack(BSON::Int64::PACK) } + let(:bson) { [ (obj.to_time.to_f * 1000).to_i ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" end diff --git a/spec/bson/decimal128_spec.rb b/spec/bson/decimal128_spec.rb index fefe846c7..7ab79d8fa 100644 --- a/spec/bson/decimal128_spec.rb +++ b/spec/bson/decimal128_spec.rb @@ -51,7 +51,7 @@ end let(:expected_bson) do - [expected_low_bits].pack(BSON::Int64::PACK) + [expected_high_bits].pack(BSON::Int64::PACK) + [expected_low_bits].pack(PackDirectives::INT64) + [expected_high_bits].pack(PackDirectives::INT64) end it 'sets the correct high order bits' do diff --git a/spec/bson/float_spec.rb b/spec/bson/float_spec.rb index ea87e6009..f9f5784e7 100644 --- a/spec/bson/float_spec.rb +++ b/spec/bson/float_spec.rb @@ -21,7 +21,7 @@ let(:type) { 1.chr } let(:obj) { 1.2332 } - let(:bson) { [ obj ].pack(Float::PACK) } + let(:bson) { [ obj ].pack(PackDirectives::FLOAT) } it_behaves_like "a bson element" it_behaves_like "a serializable bson element" diff --git a/spec/bson/int32_spec.rb b/spec/bson/int32_spec.rb index c481f91c1..c5f8abd96 100644 --- a/spec/bson/int32_spec.rb +++ b/spec/bson/int32_spec.rb @@ -67,7 +67,7 @@ let(:type) { 16.chr } let(:obj) { 123 } - let(:bson) { [ obj ].pack(BSON::Int32::PACK) } + let(:bson) { [ obj ].pack(PackDirectives::INT32) } it_behaves_like "a bson element" it_behaves_like "a deserializable bson element" @@ -76,9 +76,9 @@ describe "when the integer is negative" do let(:decoded) { -1 } - let(:encoded) { BSON::ByteBuffer.new([ -1 ].pack(BSON::Int32::PACK)) } + let(:encoded) { BSON::ByteBuffer.new([ -1 ].pack(PackDirectives::INT32)) } let(:decoded_2) { -50 } - let(:encoded_2) { BSON::ByteBuffer.new([ -50 ].pack(BSON::Int32::PACK)) } + let(:encoded_2) { BSON::ByteBuffer.new([ -50 ].pack(PackDirectives::INT32)) } it "decodes a -1 correctly" do expect(BSON::Int32.from_bson(encoded)).to eq(decoded) @@ -95,7 +95,7 @@ let(:type) { 16.chr } let(:obj) { BSON::Int32.new(Integer::MAX_32BIT - 1) } - let(:bson) { [ Integer::MAX_32BIT - 1 ].pack(BSON::Int32::PACK) } + let(:bson) { [ Integer::MAX_32BIT - 1 ].pack(PackDirectives::INT32) } it_behaves_like "a serializable bson element" end diff --git a/spec/bson/int64_spec.rb b/spec/bson/int64_spec.rb index 7d741949d..aace304e8 100644 --- a/spec/bson/int64_spec.rb +++ b/spec/bson/int64_spec.rb @@ -67,7 +67,7 @@ let(:type) { 18.chr } let(:obj) { 1325376000000 } - let(:bson) { [ obj ].pack(BSON::Int64::PACK) } + let(:bson) { [ obj ].pack(PackDirectives::INT64) } it_behaves_like "a bson element" it_behaves_like "a deserializable bson element" @@ -139,7 +139,7 @@ let(:type) { 18.chr } let(:obj) { BSON::Int64.new(Integer::MAX_64BIT - 1) } - let(:bson) { [ Integer::MAX_64BIT - 1 ].pack(BSON::Int64::PACK) } + let(:bson) { [ Integer::MAX_64BIT - 1 ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" end diff --git a/spec/bson/integer_spec.rb b/spec/bson/integer_spec.rb index 5e81af4f3..bdc255d13 100644 --- a/spec/bson/integer_spec.rb +++ b/spec/bson/integer_spec.rb @@ -23,7 +23,7 @@ let(:type) { 16.chr } let(:obj) { Integer::MAX_32BIT - 1 } - let(:bson) { [ obj ].pack(BSON::Int32::PACK) } + let(:bson) { [ obj ].pack(PackDirectives::INT32) } it_behaves_like "a serializable bson element" end @@ -32,7 +32,7 @@ let(:type) { 18.chr } let(:obj) { Integer::MAX_64BIT - 1 } - let(:bson) { [ obj ].pack(BSON::Int64::PACK) } + let(:bson) { [ obj ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" end diff --git a/spec/bson/time_spec.rb b/spec/bson/time_spec.rb index 610c353d1..20509fca9 100644 --- a/spec/bson/time_spec.rb +++ b/spec/bson/time_spec.rb @@ -28,7 +28,7 @@ context "when the time has no microseconds" do let(:obj) { Time.utc(2012, 1, 1, 0, 0, 0) } - let(:bson) { [ (obj.to_i * 1000) + (obj.usec / 1000) ].pack(BSON::Int64::PACK) } + let(:bson) { [ (obj.to_i * 1000) + (obj.usec / 1000) ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" it_behaves_like "a deserializable bson element" @@ -37,7 +37,7 @@ context "when the time has microseconds" do let(:obj) { Time.at(Time.utc(2014, 03, 22, 18, 05, 05).to_i, 505000).utc } - let(:bson) { [ (obj.to_i * 1000) + (obj.usec / 1000) ].pack(BSON::Int64::PACK) } + let(:bson) { [ (obj.to_i * 1000) + (obj.usec / 1000) ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" it_behaves_like "a deserializable bson element" @@ -47,7 +47,7 @@ context "when the time precedes epoch" do let(:obj) { Time.utc(1969, 1, 1, 0, 0, 0) } - let(:bson) { [ (obj.to_f * 1000).to_i ].pack(BSON::Int64::PACK) } + let(:bson) { [ (obj.to_f * 1000).to_i ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" it_behaves_like "a deserializable bson element" diff --git a/spec/bson/time_with_zone_spec.rb b/spec/bson/time_with_zone_spec.rb index 34271e3aa..5e4288260 100644 --- a/spec/bson/time_with_zone_spec.rb +++ b/spec/bson/time_with_zone_spec.rb @@ -50,7 +50,7 @@ context "when the TimeWithZone is not in UTC" do let(:obj) { Time.utc(2012, 12, 12, 0, 0, 0).in_time_zone("Pacific Time (US & Canada)") } - let(:bson) { [ (obj.utc.to_f * 1000).to_i ].pack(BSON::Int64::PACK) } + let(:bson) { [ (obj.utc.to_f * 1000).to_i ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" it_behaves_like 'deserializes as expected' @@ -59,7 +59,7 @@ context "when the TimeWithZone is in UTC" do let(:obj) { Time.utc(2012, 1, 1, 0, 0, 0).in_time_zone("UTC") } - let(:bson) { [ (obj.utc.to_f * 1000).to_i ].pack(BSON::Int64::PACK) } + let(:bson) { [ (obj.utc.to_f * 1000).to_i ].pack(PackDirectives::INT64) } it_behaves_like "a serializable bson element" it_behaves_like 'deserializes as expected' diff --git a/spec/bson/timestamp_spec.rb b/spec/bson/timestamp_spec.rb index bae0cc766..249d0855b 100644 --- a/spec/bson/timestamp_spec.rb +++ b/spec/bson/timestamp_spec.rb @@ -121,7 +121,7 @@ let(:type) { 17.chr } let(:obj) { described_class.new(1, 10) } - let(:bson) { [ 10, 1 ].pack(BSON::Int32::PACK * 2) } + let(:bson) { [ 10, 1 ].pack(PackDirectives::INT32 * 2) } it_behaves_like "a bson element" it_behaves_like "a serializable bson element" diff --git a/spec/support/pack_directives.rb b/spec/support/pack_directives.rb new file mode 100644 index 000000000..a5e463b98 --- /dev/null +++ b/spec/support/pack_directives.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# Pack directives used by the test suite to build reference BSON encodings. +# +# These mirror the (now deprecated) BSON::Float::PACK, BSON::Int32::PACK, and +# BSON::Int64::PACK constants. The library no longer uses those constants +# internally, so the specs keep their own copies here rather than depending on +# deprecated production constants. +module PackDirectives + # Pack directive for 8 byte floating points. + FLOAT = 'E' + + # Pack directive for little-endian 32 bit integers. + INT32 = 'l<' + + # Pack directive for little-endian 64 bit integers. + INT64 = 'q<' +end From 1048083cf0a8b885f836f2d5248080ca4969dd57 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 7 Jul 2026 15:40:53 -0600 Subject: [PATCH 3/8] deprecate Int32::BYTES_LENGTH, don't just remove it --- lib/bson/int32.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/bson/int32.rb b/lib/bson/int32.rb index 4f73fa8c3..9ad612fbb 100644 --- a/lib/bson/int32.rb +++ b/lib/bson/int32.rb @@ -29,6 +29,14 @@ class Int32 # @since 2.0.0 BSON_TYPE = ::String.new(16.chr, encoding: BINARY).freeze + # The number of bytes constant. + # + # @since 4.0.0 + # @deprecated No longer used internally; retained for backward + # compatibility and slated for removal in a future major version. + BYTES_LENGTH = 4 + deprecate_constant :BYTES_LENGTH + # Constant for the int 32 pack directive. # # @since 2.0.0 From 384c635057d3992fb214a2ae9be2bafacdd4577e Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 7 Jul 2026 15:46:47 -0600 Subject: [PATCH 4/8] RUBY-3814 deprecate unused BSON_ARRAY_INDEXES and BSON_INDEX_SIZE These constants were an array-index serialization optimization made obsolete by the RUBY-1019 ByteBuffer rewrite in 2015. They have been unreferenced ever since. Deprecate rather than remove, consistent with the other dead constants in this branch. --- lib/bson/integer.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/bson/integer.rb b/lib/bson/integer.rb index 271076892..e2ea1cbc6 100644 --- a/lib/bson/integer.rb +++ b/lib/bson/integer.rb @@ -47,15 +47,24 @@ module Integer # The BSON index size. # # @since 2.0.0 + # @deprecated No longer used internally; retained for backward + # compatibility and slated for removal in a future major version. BSON_INDEX_SIZE = 1024 # A hash of index values for array optimization. # # @since 2.0.0 + # @deprecated No longer used internally; retained for backward + # compatibility and slated for removal in a future major version. BSON_ARRAY_INDEXES = ::Array.new(BSON_INDEX_SIZE) do |i| (i.to_s.b << NULL_BYTE).freeze end.freeze + # Deprecated after BSON_ARRAY_INDEXES is built, since that (also + # deprecated) constant references BSON_INDEX_SIZE at load time. + deprecate_constant :BSON_INDEX_SIZE + deprecate_constant :BSON_ARRAY_INDEXES + # Is this integer a valid BSON 32 bit value? # # @example Is the integer a valid 32 bit value? From 4f87d969fc48daacfc46050e11bded2be3e70859 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 7 Jul 2026 15:47:32 -0600 Subject: [PATCH 5/8] remove previously-deprecated constant --- lib/bson/regexp.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/bson/regexp.rb b/lib/bson/regexp.rb index 22304d3d8..020a700f1 100644 --- a/lib/bson/regexp.rb +++ b/lib/bson/regexp.rb @@ -50,13 +50,6 @@ module Regexp # @since 3.2.6 NEWLINE_VALUE = 's' - # Ruby multiline constant. - # - # @since 3.2.6 - # - # @deprecated Will be removed in 5.0 - RUBY_MULTILINE_VALUE = 'ms' - # Get the regexp as JSON hash data. # # @example Get the regexp as a JSON hash. From 3de7e193d094c20677ee28138e75ea86b2594784 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 7 Jul 2026 15:53:01 -0600 Subject: [PATCH 6/8] as_json is still used internally; rather than mark it deprecated, let's just leave it as an alias --- lib/bson/timestamp.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/bson/timestamp.rb b/lib/bson/timestamp.rb index c21c0f9df..aa7812add 100644 --- a/lib/bson/timestamp.rb +++ b/lib/bson/timestamp.rb @@ -86,7 +86,6 @@ def <=>(other) # @return [ Hash ] The timestamp as a JSON hash. # # @since 2.0.0 - # @deprecated Use as_extended_json instead. def as_json(*args) as_extended_json end From 33447be5692a866b17983ea19a2d36e405196a73 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 7 Jul 2026 15:59:54 -0600 Subject: [PATCH 7/8] remove deprecated constants (deprecated pre-5.0) --- lib/bson/dbref.rb | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/bson/dbref.rb b/lib/bson/dbref.rb index 851863294..2016fcb34 100644 --- a/lib/bson/dbref.rb +++ b/lib/bson/dbref.rb @@ -21,21 +21,6 @@ module BSON class DBRef < Document include JSON - # The constant for the collection reference field. - # - # @deprecated - COLLECTION = '$ref'.freeze - - # The constant for the id field. - # - # @deprecated - ID = '$id'.freeze - - # The constant for the database field. - # - # @deprecated - DATABASE = '$db'.freeze - # @return [ String ] collection The collection name. def collection self['$ref'] From 23a45bbf1b14eb174f398c1796ad52a183c6d426 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 7 Jul 2026 16:03:32 -0600 Subject: [PATCH 8/8] we don't support ruby 1.9 anymore --- lib/bson/environment.rb | 13 ------------- lib/bson/open_struct.rb | 6 +----- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/bson/environment.rb b/lib/bson/environment.rb index 1f253b1fc..62360fc31 100644 --- a/lib/bson/environment.rb +++ b/lib/bson/environment.rb @@ -34,18 +34,5 @@ module Environment def jruby? @jruby ||= defined?(JRUBY_VERSION) end - - # Determine if we are using Ruby version 1.9. - # - # @example Are we running with Ruby version 1.9? - # Environment.ruby_1_9? - # - # @return [ true, false ] If the Ruby version is 1.9. - # - # @since 4.2.0 - # @deprecated - def ruby_1_9? - @ruby_1_9 ||= RUBY_VERSION < '2.0.0' - end end end diff --git a/lib/bson/open_struct.rb b/lib/bson/open_struct.rb index 883037a8c..61dfd6d4c 100644 --- a/lib/bson/open_struct.rb +++ b/lib/bson/open_struct.rb @@ -35,11 +35,7 @@ module OpenStruct # # @since 4.2.0 def to_bson(buffer = ByteBuffer.new) - if Environment.ruby_1_9? - marshal_dump.dup - else - to_h - end.to_bson(buffer) + to_h.to_bson(buffer) end # The BSON type for OpenStruct objects is the Hash type of 0x03.