diff --git a/lib/yaml/dbm.rb b/lib/yaml/dbm.rb index 126d72dd4d..a3cbaeccf6 100644 --- a/lib/yaml/dbm.rb +++ b/lib/yaml/dbm.rb @@ -1,6 +1,10 @@ # frozen_string_literal: false require 'yaml' -require 'dbm' + +begin + require 'dbm' +rescue LoadError +end module YAML @@ -288,4 +292,4 @@ class DBM < ::DBM alias :each :each_pair end -end +end if defined?(DBM) diff --git a/test/yaml/test_dbm.rb b/test/yaml/test_dbm.rb index 15d441d23b..cf50256298 100644 --- a/test/yaml/test_dbm.rb +++ b/test/yaml/test_dbm.rb @@ -43,4 +43,4 @@ class TestYAMLDBM < Test::Unit::TestCase @dbm["key"] = "value" assert_equal ["key", "value"], @dbm.shift end -end \ No newline at end of file +end if defined?(YAML::DBM)