Sha256: 3a752bd61b741e354a34cf887cd76b09bf872886eeeba91a59503d6b42eb0add
Contents?: true
Size: 1.27 KB
Versions: 86
Compression:
Stored size: 1.27 KB
Contents
module Origen class OrgFile module Interceptable def self.included(base) base.extend ClassMethods end module ClassMethods def new(*args, &block) o = allocate i = OrgFile::Interceptor.new(o) o.__interceptor__ = i i.send(:initialize, *args, &block) unless o.respond_to?(:global_path_to) puts 'When adding the OrgFile::Interceptable module to a class, the class must define an instance method called "global_path_to", like this:' puts puts ' # Must return a string that contains a global path to access the given object,' puts ' # here for example if the object was a pin' puts ' def global_path_to' puts ' "dut.pins(:#{id})"' puts ' end' fail "Incomplete integration of OrgFile::Interceptable in #{o.class}" end i end end # Class which include OrgFile::Interceptor should use 'myself' anytime then want to reference 'self', # this ensures that there are never any references to the unwrapped object def myself @__interceptor__ end # @api private def __interceptor__=(obj) @__interceptor__ = obj end end end end
Version data entries
86 entries across 86 versions & 1 rubygems