Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix to prevent "try" function redefinition when it already exists.

We already use a more generic try function.

mofo overrides our better try method so let's prevent this

A better try method is

    def try(method, *args)
      send(method, *args) if respond_to?(method)
    end

With this, we can also do some stuff like item.try(:key=, value)
  • Loading branch information...
commit 27e25eed46990434ea493e94753709018085bbc6 1 parent 377b040
Olivier Ruffin authored September 08, 2008 dustin committed October 29, 2008

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. 8  lib/microformat/object.rb
8  lib/microformat/object.rb
... ...
@@ -1,5 +1,7 @@
1  
-class Object
2  
-  def try(property)
3  
-    send property if respond_to? property
  1
+unless Object.method_defined?(:try)
  2
+  class Object
  3
+    def try(property)
  4
+      send property if respond_to? property
  5
+    end
4 6
   end
5 7
 end

0 notes on commit 27e25ee

Please sign in to comment.
Something went wrong with that request. Please try again.