Module: UIC::ElementBacked::ClassMethods

Instance Method Summary collapse

Instance Method Details

#xmlattribute(name, getblock = nil, &setblock) ⇒ Object

Add methods to instances of the class which gets/sets from an XML attribute.

Parameters:

  • name (String)

    the name of an XML attribute to expose.

  • getblock (Proc) (defaults to: nil)

    a proc to run to fetch the value.



107
108
109
110
# File 'lib/ruic/interfaces.rb', line 107

def xmlattribute(name,getblock=nil,&setblock)
	define_method(name){ getblock ? getblock[@el[name],self] : @el[name] }
	define_method("#{name}="){ |new_value| @el[name] = (setblock ? setblock[new_value,self] : new_value).to_s }
end