Sha256: 57eed2c9fda1a909e026475c85ace00e2a627705abf894f1518d338c782ca51c
Contents?: true
Size: 973 Bytes
Versions: 11
Compression:
Stored size: 973 Bytes
Contents
module Massimo module Reloader extend self def load(name = :default) cache[name] ||= {} previous_constants = Object.constants previous_features = $LOADED_FEATURES.dup yield if block_given? cache[name][:constants] = (Object.constants - previous_constants).uniq cache[name][:features] = ($LOADED_FEATURES - previous_features).uniq cache[name] end def unload(name = :default) return unless cache.key?(name) cache[name][:constants].reject! do |const| Object.send(:remove_const, const) if Object.const_defined?(const) end if cache[name].key?(:constants) cache[name][:features].reject! do |feature| $LOADED_FEATURES.delete(feature) end if cache[name].key?(:features) cache[name] end def reload(name = :default, &block) unload(name) load(name, &block) end def cache @cache ||= {} end end end
Version data entries
11 entries across 11 versions & 1 rubygems