summaryrefslogtreecommitdiff
path: root/ext/digest/lib
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-14 12:45:59 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-14 12:45:59 +0000
commit559be019deb5b8996842456360291182da1898ba (patch)
tree90aec32119b2d5c5f25917c6b68157eb758caebe /ext/digest/lib
parentb9084ef40826d53bfd3a09c926b6d1c0eaf1645e (diff)
* ext/digest/lib/digest.rb (Digest::self.const_missing): Drop
autoloads for sha2 classes in favor of handling in const_missing(), to work around a problem exposed on OS X. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest/lib')
-rw-r--r--ext/digest/lib/digest.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/ext/digest/lib/digest.rb b/ext/digest/lib/digest.rb
index a56d475..244cd43 100644
--- a/ext/digest/lib/digest.rb
+++ b/ext/digest/lib/digest.rb
@@ -1,19 +1,21 @@
require 'digest.so'
module Digest
- autoload "SHA256", "digest/sha2.so"
- autoload "SHA384", "digest/sha2.so"
- autoload "SHA512", "digest/sha2.so"
-
def self.const_missing(name)
- begin
- require File.join('digest', name.downcase)
+ case name
+ when :SHA256, :SHA384, :SHA512
+ lib = 'digest/sha2.so'
+ else
+ lib = File.join('digest', name.to_s.downcase)
+ end
- return Digest.const_get(name) if Digest.const_defined?(name)
+ begin
+ require lib
rescue LoadError => e
+ raise LoadError, "library not found for class Digest::#{name} -- #{lib}"
end
- raise NameError, "Digest class not found: Digest::#{name}"
+ Digest.const_get(name)
end
class ::Digest::Class