U
Une bévue
i've a class "Preferences"
which includes other classes for example "Theme"
i save an instance of "Preferences" by writing self.to_yaml into a file.
obviously, i want to retrive this instance back by :
o=YAML::load(File.open("#{PREFS_FILE}"))
PREFS_FILE being the preceedingly saved one.
what's the best way to "re-populate" my classes ?
for the time being i'm doing :
o.themes_list.each { |theme|
t=Theme.new(theme.label)
t.nb_cols_list=theme.nb_cols_list
@themes_list << t
}
[...]
@theme_label=o.theme_label
@nb_cols=o.nb_cols
does exist a more direct way to do the samething ?
which includes other classes for example "Theme"
i save an instance of "Preferences" by writing self.to_yaml into a file.
obviously, i want to retrive this instance back by :
o=YAML::load(File.open("#{PREFS_FILE}"))
PREFS_FILE being the preceedingly saved one.
what's the best way to "re-populate" my classes ?
for the time being i'm doing :
o.themes_list.each { |theme|
t=Theme.new(theme.label)
t.nb_cols_list=theme.nb_cols_list
@themes_list << t
}
[...]
@theme_label=o.theme_label
@nb_cols=o.nb_cols
does exist a more direct way to do the samething ?