Sha256: 3609a2989f4c09ba74a2934abc38a80818007afc58a830d143e850aae9057037

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

module Bogus
  module HasOverwritenMethods
    def __overwritten_methods__
      @__overwritten_methods__ ||= {}
    end

    def __overwrite__(name, method, body)
      return if __overwritten_methods__[name]
      method = method.to_proc if method
      __overwritten_methods__[name] = method || :no_such_method
      instance_eval(body)
    end

    def __reset__
      __overwritten_methods__.each do |name, method|
        method = __overwritten_methods__.delete(name)
        instance_eval "undef #{name}"
        next if method == :no_such_method
        define_singleton_method(name, method)
      end
      @__overwritten_methods__ = {}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bogus-0.0.3.rc.1 lib/bogus/has_overwritten_methods.rb