class Module

Public Instance Methods

attr_property(*symbols) click to toggle source

dsl method for declaring attribute setters which result in widget being repainted. Also, fire a fire_property_change event. @param symbols [Symbol] value to be set @return [Widget] self

# File lib/umbra/widget.rb, line 16
def attr_property(*symbols)
  symbols.each { |sym|
    class_eval %{
      def #{sym}=(val)
        oldvalue = @#{sym}
        newvalue = val
        if @_object_created.nil?
           @#{sym} = newvalue
        end
        # return(self) if oldvalue.nil? || @_object_created.nil?
        return(self) if @_object_created.nil?

        if oldvalue != newvalue
          begin
            fire_property_change("#{sym}", oldvalue, newvalue)
            @#{sym} = newvalue
          rescue PropertyVetoException
            $log.warn "PropertyVetoException for #{sym}:" + oldvalue.to_s + "->  "+ newvalue.to_s
          end
        end # oldvalue !=
        self
      end # def
  attr_reader sym
    }
  }
end