Skip to content

Instantly share code, notes, and snippets.

@kml
Last active November 10, 2015 09:31
Show Gist options
  • Save kml/349d3ae1716e6500cbee to your computer and use it in GitHub Desktop.
Save kml/349d3ae1716e6500cbee to your computer and use it in GitHub Desktop.
# encoding: utf-8
# Source: https://gist.github.com/kml/349d3ae1716e6500cbee
# Benchmark: https://gist.github.com/kml/0fb1588fc1b6ba4c60fa
# Issue: https://github.com/solnic/coercible/pull/22
# https://github.com/solnic/coercible/blob/master/lib/coercible/coercer/object.rb#L163
require "coercible"
if Coercible::VERSION != "1.0.0"
abort "#{__FILE__}: Check if coercible gem still needs this patch!"
end
module Coercible
class Coercer
class Object
private
def method_missing(method, *args)
if method.to_s =~ COERCION_METHOD_REGEXP && args.size == 1
self.class.send(:define_method, method) do |value|
value
end
return args.first
end
super
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment