Permalink
Browse files

Fix X11 proxy constant lookup under 1.9+

  • Loading branch information...
1 parent db0749b commit 594590e5ad52ddcf1736f8fd2863a84d018beb50 @jacknagel jacknagel committed Feb 19, 2013
Showing with 20 additions and 10 deletions.
  1. +20 −10 Library/Homebrew/requirements.rb
@@ -109,19 +109,29 @@ def self.inherited(mod)
class Proxy < self
PACKAGES = [:libpng, :freetype, :fontconfig]
- def self.for(name, *tags)
- constant = name.capitalize
-
- if const_defined?(constant)
- klass = const_get(constant)
- else
- klass = Class.new(self) do
- def initialize(name, *tags) super end
+ class << self
+ def defines_const?(const)
+ if ::RUBY_VERSION >= "1.9"
+ const_defined?(const, false)
+ else
+ const_defined?(const)
end
+ end
- const_set(constant, klass)
+ def for(name, *tags)
+ constant = name.capitalize
+
+ if defines_const?(constant)
+ klass = const_get(constant)
+ else
+ klass = Class.new(self) do
+ def initialize(name, *tags) super end
+ end
+
+ const_set(constant, klass)
+ end
+ klass.new(name, *tags)
end
- klass.new(name, *tags)
end
end
end

0 comments on commit 594590e

Please sign in to comment.