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.59.7 lib/origen/org_file/interceptable.rb
origen-0.59.6 lib/origen/org_file/interceptable.rb
origen-0.59.5 lib/origen/org_file/interceptable.rb
origen-0.59.4 lib/origen/org_file/interceptable.rb
origen-0.59.3 lib/origen/org_file/interceptable.rb
origen-0.59.2 lib/origen/org_file/interceptable.rb
origen-0.59.1 lib/origen/org_file/interceptable.rb
origen-0.59.0 lib/origen/org_file/interceptable.rb
origen-0.58.0 lib/origen/org_file/interceptable.rb
origen-0.57.2 lib/origen/org_file/interceptable.rb
origen-0.57.1 lib/origen/org_file/interceptable.rb
origen-0.57.0 lib/origen/org_file/interceptable.rb
origen-0.56.0 lib/origen/org_file/interceptable.rb
origen-0.55.5 lib/origen/org_file/interceptable.rb
origen-0.55.4 lib/origen/org_file/interceptable.rb
origen-0.55.3 lib/origen/org_file/interceptable.rb
origen-0.55.2 lib/origen/org_file/interceptable.rb
origen-0.55.1 lib/origen/org_file/interceptable.rb
origen-0.55.0 lib/origen/org_file/interceptable.rb
origen-0.54.6 lib/origen/org_file/interceptable.rb