Sha256: e2670e71421111cc171ba8c8c5c126dd6d807a1cd4e2519ace9b61e73c86c622

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

module Parameters
  class InstanceParam < Param

    # Owning object
    attr_reader :object

    #
    # Creates a new InstanceParam object with the specified _object_ and
    # _name_, and the given _description_.
    #
    def initialize(object,name,description='')
      super(name,description)

      @object = object
    end

    #
    # Returns the value of the instance param.
    #
    def value
      @object.instance_variable_get("@#{@name}")
    end

    #
    # Sets the value of the instance param.
    #
    def value=(value)
      @object.instance_variable_set("@#{@name}",value)
    end

    #
    # Inspects the instance params value.
    #
    def inspect
      value.inspect
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parameters-0.1.0 lib/parameters/instance_param.rb