T
T. Onoma
has anyone given any thought to having macros in ruby?
perhaps there's another way to do what i want, but i'm not sure. i keep reusing the same snippit of code over and over in this one class that includes a few variables, a dumbed-down example:
"/Path/To/#{variable}/Directory"
with such a simple example one would think i only needed to set an @variable to it and resuse that, but this class is usually marshalled via yaml and hence loaded using YAML::load, so initialize will not be run. the upshot of this is that i have no single place in the class that's definitely going to be excecuted where i can set the variable. so what do you do without repeating the same snippet over and over?
oh, of course i could write a method to do it and call that each time. but this snippet really should be in a configuration file of some sort. from the example above, b/c the exact path could change.
hmmm...guess there's always eval.
thoughts?
-t0
perhaps there's another way to do what i want, but i'm not sure. i keep reusing the same snippit of code over and over in this one class that includes a few variables, a dumbed-down example:
"/Path/To/#{variable}/Directory"
with such a simple example one would think i only needed to set an @variable to it and resuse that, but this class is usually marshalled via yaml and hence loaded using YAML::load, so initialize will not be run. the upshot of this is that i have no single place in the class that's definitely going to be excecuted where i can set the variable. so what do you do without repeating the same snippet over and over?
oh, of course i could write a method to do it and call that each time. but this snippet really should be in a configuration file of some sort. from the example above, b/c the exact path could change.
hmmm...guess there's always eval.
thoughts?
-t0