Skip to content

Instantly share code, notes, and snippets.

@egwspiti
Last active August 29, 2015 14:23
Show Gist options
  • Save egwspiti/e450588a8585d23e1fa2 to your computer and use it in GitHub Desktop.
Save egwspiti/e450588a8585d23e1fa2 to your computer and use it in GitHub Desktop.
xxx = Symbol.method_defined?(:call) && Symbol.instance_method(:call)
Symbol.class_eval { undef :call } if xxx
# some code that fails when call is defined on Symbol
Symbol.instance_eval { define_method(:call, xxx) } if xxx
@kyrylo
Copy link

kyrylo commented Jun 30, 2015

def stfu_slop
  call_method = nil

  if Symbol.method_defined?(:call)
    call_method = Symbol.instance_method(:call)
    Symbol.class_eval { undef :call }
  end

  yield
ensure
  Symbol.instance_eval { define_method(:call, call_method) } if call_method
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment