Sha256: e22f9d525bddec20ee16ffaf58509e39010a877aa91d2ec6454e088e285fd734
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
require_relative 'state_inspector' require_relative 'reporter' module StateInspector module Snoop def Snoop.extended(base) base.include ClassMethods end module ClassMethods def state_inspector StateInspector.new(self) end def tell_si *args, &block if informant? key = self.respond_to?(:class_exec) ? self : self.class key = Reporter.has_key?(key) ? key : self Reporter[key].update(self, *args, &block) end end def toggle_informant state_inspector.snoop_setters( *(self.respond_to?(:class_exec) ? self : self.class). instance_methods.grep(/=\z/) - Object.methods ) unless @state_inspector || self.class.instance_variable_get(:@state_inspector) @informant = !@informant end def informant? @informant || self.class.instance_variable_get(:@informant) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
state_inspector-1.0.5 | lib/state_inspector/snoop.rb |
state_inspector-1.0.4 | lib/state_inspector/snoop.rb |