Sha256: 59db4d1f97ff3e81d9da34adf854eb184c938b5039095a46dee914f602941ca5
Contents?: true
Size: 583 Bytes
Versions: 1
Compression:
Stored size: 583 Bytes
Contents
class Object def stub(methot, value) singleton_methot_exists = respond_to?(methot) && singleton_methods.include?(methot) if singleton_methot_exists original = "__original_#{methot}__" singleton_class.class_eval { alias_method(original, methot) } end define_singleton_method(methot) { |*arguments| value } yield if singleton_methot_exists singleton_class.class_eval do alias_method(methot, original) remove_method(original) end else singleton_class.class_eval { remove_method(methot) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
defekt-0.0.3 | lib/defekt/object.rb |