diff --git a/lib/haml/util.rb b/lib/haml/util.rb index a390f61a..b0128379 100755 --- a/lib/haml/util.rb +++ b/lib/haml/util.rb @@ -172,24 +172,6 @@ MSG end end - # Checks to see if a class has a given method. - # For example: - # - # Haml::Util.has?(:public_instance_method, String, :gsub) #=> true - # - # Method collections like `Class#instance_methods` - # return strings in Ruby 1.8 and symbols in Ruby 1.9 and on, - # so this handles checking for them in a compatible way. - # - # @param attr [#to_s] The (singular) name of the method-collection method - # (e.g. `:instance_methods`, `:private_methods`) - # @param klass [Module] The class to check the methods of which to check - # @param method [String, Symbol] The name of the method do check for - # @return [Boolean] Whether or not the given collection has the given method - def has?(attr, klass, method) - klass.send("#{attr}s").detect {|x| x.to_s == method.to_s} - end - # Like `Object#inspect`, but preserves non-ASCII characters rather than escaping them under Ruby 1.9.2. # This is necessary so that the precompiled Haml template can be `#encode`d into `@options[:encoding]` # before being evaluated. diff --git a/test/util_test.rb b/test/util_test.rb index 6d23f317..2d47e655 100644 --- a/test/util_test.rb +++ b/test/util_test.rb @@ -43,11 +43,6 @@ class UtilTest < MiniTest::Unit::TestCase $stderr = old_stderr end - def test_has - assert(has?(:instance_method, String, :chomp!)) - assert(has?(:private_instance_method, Haml::Engine, :set_locals)) - end - def test_caller_info assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle'")) assert_equal(["/tmp/foo.rb", 12, nil], caller_info("/tmp/foo.rb:12"))