lib/surrogate/method_definition.rb in surrogate-0.6.1 vs lib/surrogate/method_definition.rb in surrogate-0.6.2

- old
+ new

@@ -37,19 +37,25 @@ end private def errorizer - @errorizer ||= ArgumentErrorizer.new name, default_proc + @errorizer ||= ArgumentErrorizer.new name, to_method_definition(default_proc) end def default_proc_as_method_on(instance) unique_name = "surrogate_temp_method_#{Time.now.to_i}_#{rand 10000000}" klass = instance.singleton_class klass.__send__ :define_method, unique_name, &default_proc as_method = klass.instance_method unique_name klass.__send__ :remove_method, unique_name as_method.bind instance + end + + def to_method_definition(default_proc) + object = Object.new + object.define_singleton_method(:temp_method, &default_proc) + object.method(:temp_method) end end end