Sha256: 4a32eccd7caf1a3a2a84abac28e8e1698c8a84f404b055e9ac662656165e7175
Contents?: true
Size: 1.35 KB
Versions: 11
Compression:
Stored size: 1.35 KB
Contents
module Mocktail class TopShelf def self.instance Thread.current[:mocktail_top_shelf] ||= new end @@type_replacements = {} @@type_replacements_mutex = Mutex.new def initialize @new_registrations = [] @of_next_registrations = [] @singleton_method_registrations = [] end def type_replacement_for(type) @@type_replacements_mutex.synchronize { @@type_replacements[type] ||= TypeReplacement.new(type: type) } end def type_replacement_if_exists_for(type) @@type_replacements_mutex.synchronize { @@type_replacements[type] } end def reset_current_thread! Thread.current[:mocktail_top_shelf] = self.class.new end def register_new_replacement!(type) @new_registrations |= [type] end def new_replaced?(type) @new_registrations.include?(type) end def register_of_next_replacement!(type) @of_next_registrations |= [type] end def of_next_registered?(type) @of_next_registrations.include?(type) end def unregister_of_next_replacement!(type) @of_next_registrations -= [type] end def register_singleton_method_replacement!(type) @singleton_method_registrations |= [type] end def singleton_methods_replaced?(type) @singleton_method_registrations.include?(type) end end end
Version data entries
11 entries across 11 versions & 1 rubygems