Sha256: 44ad01857048c73abbfe7aab846c327853bcecde9b1fac0bec7e383f1614903d

Contents?: true

Size: 926 Bytes

Versions: 119

Compression:

Stored size: 926 Bytes

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

      # 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

119 entries across 119 versions & 1 rubygems

Version Path
origen-0.7.30 lib/origen/pins/function_proxy.rb
origen-0.7.29 lib/origen/pins/function_proxy.rb
origen-0.7.28 lib/origen/pins/function_proxy.rb
origen-0.7.27 lib/origen/pins/function_proxy.rb
origen-0.7.26 lib/origen/pins/function_proxy.rb
origen-0.7.25 lib/origen/pins/function_proxy.rb
origen-0.7.24 lib/origen/pins/function_proxy.rb
origen-0.7.23 lib/origen/pins/function_proxy.rb
origen-0.7.22 lib/origen/pins/function_proxy.rb
origen-0.7.21 lib/origen/pins/function_proxy.rb
origen-0.7.20 lib/origen/pins/function_proxy.rb
origen-0.7.19 lib/origen/pins/function_proxy.rb
origen-0.7.18 lib/origen/pins/function_proxy.rb
origen-0.7.17 lib/origen/pins/function_proxy.rb
origen-0.7.16 lib/origen/pins/function_proxy.rb
origen-0.7.15 lib/origen/pins/function_proxy.rb
origen-0.7.14 lib/origen/pins/function_proxy.rb
origen-0.7.13 lib/origen/pins/function_proxy.rb
origen-0.7.12 lib/origen/pins/function_proxy.rb
origen-0.7.11 lib/origen/pins/function_proxy.rb