[Nitro] Using Og with GUI

TRANS transfire at gmail.com
Thu Sep 15 21:08:47 EDT 2005

On 9/15/05, David Legard <dalegard at gmail.com> wrote:
> I am using Og to drive a GUI-based application, which uses several onscreen
> controls, button, text boxes and the like. 
> Obviously, I have to extract information from the controls called 'name',
> 'date', 'address' etc for Og to write away to the database. 
> As I am quite strict with naming conventions, I find myself writing a lot of
> code like: 
> m.name=getControlValue('name') 
> m.date=getControlValue('date') 
> m.address=getControlValue('address') 
> m.phone=getControlValue('phone') 
> . 
> . 
> . 
> . 
> Is there any way I can tie the control 'name' to the object attribute
> 'm.name' and so on, to avoid having to write all this repetitive code? 
> Ideally I would like to write something like: 
> allControls.each do |k| 
>   m.k=getControlValue(k) 
> end 

You can do this

  allControls.each do |k| 
    m.send( "#{k}=", getControlValue(k)  )

But perhaps ther is a better way. If all the values are coming from
the controls you could define your own attributes:

  def name


More information about the Nitro-general mailing list