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

Version Path
origen-0.60.19 lib/origen/org_file/interceptable.rb
origen-0.60.18 lib/origen/org_file/interceptable.rb
origen-0.60.17 lib/origen/org_file/interceptable.rb
origen-0.60.16 lib/origen/org_file/interceptable.rb
origen-0.60.14 lib/origen/org_file/interceptable.rb
origen-0.60.13 lib/origen/org_file/interceptable.rb
origen-0.60.12 lib/origen/org_file/interceptable.rb
origen-0.60.11 lib/origen/org_file/interceptable.rb
origen-0.60.10 lib/origen/org_file/interceptable.rb
origen-0.60.9 lib/origen/org_file/interceptable.rb
origen-0.60.8 lib/origen/org_file/interceptable.rb
origen-0.60.7 lib/origen/org_file/interceptable.rb
origen-0.60.6 lib/origen/org_file/interceptable.rb
origen-0.60.5 lib/origen/org_file/interceptable.rb
origen-0.60.4 lib/origen/org_file/interceptable.rb
origen-0.60.3 lib/origen/org_file/interceptable.rb
origen-0.60.2 lib/origen/org_file/interceptable.rb
origen-0.60.1 lib/origen/org_file/interceptable.rb
origen-0.60.0 lib/origen/org_file/interceptable.rb
origen-0.59.8 lib/origen/org_file/interceptable.rb