Widget Configurability via YAML?
Just to follow up on my “previous post”:http://lylejohnson.name/blog/?p=130: Most who responded on the ruby-talk list liked the proposed API change for FXRuby. “Dan Berger”:http://www.livejournal.com/users/djberg96/ noted that I should be sure to make it so that strings could be used in place of symbols, e.g.
splitter.expand("topleft", "topright")
should be equivalent to:
splitter.expand(:topleft, :topright)
Ara Howard added that accepting string values as inputs could make it easier to configure a widget via “YAML”:http://yaml4r.sourceforge.net/. For example, suppose that all widgets had a @configure@ method that took a hash:
splitter.configure({
"expand" => ["topleft", "topright"],
"foo" => "bar"
})
Now if you had a file @config.yml@ containing the YAML representation of that hash:
---
expand:
- topleft
- topright
foo: bar
You could then configure the widget in one line using:
splitter.configure(YAML::load(IO::read('config.yml')))
Now, I said that most folks like the proposed changes. Simon Kröger is (so far) the lone dissenter, and he didn’t see all that much that was wrong with the current approach. He did propose an alternative approach that involved treating the attribute (here, @FX4Splitter#expanded@) as a @Symbol@ but also delegating some of the work to a @Set@. It seemed a little convoluted for my taste but it’s good to see other ways to think about the problem.
i’d also like configuration by YAML – for it seems extremly practical for foxGUIb.
February 16th, 2006 at 2:10 am