Sha256: 165da9ab2e919fa1f87c8d36fd94f313b5a1b7671ba5c506981cc2e42542ab2d
Contents?: true
Size: 1001 Bytes
Versions: 1
Compression:
Stored size: 1001 Bytes
Contents
require_relative "replaces_type/redefines_new" require_relative "replaces_type/redefines_singleton_methods" require_relative "replaces_type/runs_sorbet_sig_blocks_before_replacement" module Mocktail class ReplacesType extend T::Sig def initialize @top_shelf = TopShelf.instance @runs_sorbet_sig_blocks_before_replacement = RunsSorbetSigBlocksBeforeReplacement.new @redefines_new = RedefinesNew.new @redefines_singleton_methods = RedefinesSingletonMethods.new end def replace(type) unless type.is_a?(Class) || type.is_a?(Module) raise UnsupportedMocktail.new("Mocktail.replace() only supports classes and modules") end @runs_sorbet_sig_blocks_before_replacement.run(type) if type.is_a?(Class) @top_shelf.register_new_replacement!(type) @redefines_new.redefine(type) end @top_shelf.register_singleton_method_replacement!(type) @redefines_singleton_methods.redefine(type) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mocktail-2.0.0 | lib/mocktail/replaces_type.rb |