Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/umbra/widget.rb
Overview
{{{
Instance Method Summary collapse
-
#attr_property(*symbols) ⇒ Widget
dsl method for declaring attribute setters which result in widget being repainted.
Instance Method Details
#attr_property(*symbols) ⇒ Widget
dsl method for declaring attribute setters which result in widget being repainted. Also, fire a #fire_property_change event.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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 |