Sha256: e20fb5656e2aec4055408bf07145441a32b7348d1939f4d0a4bc208c3b83442c

Contents?: true

Size: 1.11 KB

Versions: 87

Compression:

Stored size: 1.11 KB

Contents

module Origen
  module Pins
    require 'delegate'
    require 'origen/pins/pin'
    # Thin wrapper around pin objects to implement a defined function.
    #
    # The pin object stores all attributes associated with the function, this
    # wrapper simply keeps track of what function a given pin reference refers to
    class FunctionProxy < ::Delegator
      def initialize(id, pin)
        @id = id
        @pin = pin
      end

      def __getobj__
        @pin
      end

      # @api private
      #
      # To play nicely with == when a function proxy is wrapping a pin that is already
      # wrapped by an OrgFile interceptor
      def __object__
        @pin.__object__
      end

      # Intercept all calls to function-scoped attributes of the pin so
      # that we can inject the function that we want the attribute value for
      Pin::FUNCTION_SCOPED_ATTRIBUTES.each do |attribute|
        define_method attribute do |options = {}|
          options[:function] = @id
          @pin.send(attribute, options)
        end
      end

      private

      # For debug
      def _function
        @id
      end
    end
  end
end

Version data entries

87 entries across 87 versions & 1 rubygems

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