Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 veilleperso authored dustin committed
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/microformat/object.rb
8 lib/microformat/object.rb
View
@@ -1,5 +1,7 @@
-class Object
- def try(property)
- send property if respond_to? property
+unless Object.method_defined?(:try)
+ class Object
+ def try(property)
+ send property if respond_to? property
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.