[Nitro] Building objects from Strings

Michael Fellinger manveru at weez-int.com
Wed Aug 9 05:07:33 EDT 2006

On Wednesday 09 August 2006 17:41, gabriele renzi wrote:
> Hi everyone,
> I have a somewhat working interface to change Settings from the
> administration UI, and I think it is a Good Thing(TM).
> But bat the moment it is slightly fragile, and uses a hacky way of
> getting the values from the user.
> Basically, I'm providigin small text fields for each "good" setting, and
> in the server side I'm assigning to the setting the value by
> transforming it in the right type.
> In code:
>   setting.value = setting.type.new(param[name])
> Now to the bad one: ruby does not have String constructors for many
> things, so the above is working fine for String and Numerics.
> I added the handling for Booleans as a simple
> def TrueClass.new(arg) arg=='true' end
> def FalseClass.new(arg) not TrueClass.new(arg) end
> A better solution could be using YAML.load on the given String.
> Someone has other ideas or could point me to something in facets (i.e.
> core/kernel/parse_literal) ?

did you think about checkboxes?

Weez International Limited

East Roppongi Bldg 5F, 509
3-16-35 Roppongi, Minato-ku Tokyo #106-0032
Tel: 81-(0)3-3505-3881 Fax: 81-(0)3-3505-3883
E-mail: manveru at weez-int.com
Website: http://weez-int.com

More information about the Nitro-general mailing list