I am searching for the best way to do a dynamic mixin with Ruby.
Basically I have a class that includes a mixin but I want the mixin
module
name to be driven from configuration and not the code.
class A
include Foo
end
but instead of Foo being constant module name, I would this to be driven
off
of a configuration value. (I’m not too worried about the module being
loaded
previously that is easily taken care of, so primarily just wanting to
know
the best way to do a dynamic include).
Any opinions on the best way to accomplish this?
A very simple way to approach this might be something like
but instead of Foo being constant module name, I would this to be driven off
of a configuration value. (I’m not too worried about the module being loaded
previously that is easily taken care of, so primarily just wanting to know
the best way to do a dynamic include).
Any opinions on the best way to accomplish this?
A very simple way to approach this might be something like
ModToInclude = ‘Foo’
ModToInclude = ‘Foo; system “sudo rm -rf /”’
class A
eval( “include #{ModToInclude}” )
end
Any better ideas?
def factory plugin
plugins = {
:foo => Foo,
:bar => Bar,
}
Class.new{
include plugins[ plugin ]
}
end
Ugh. I get shivers just seeing this sort of thing in ‘print’. It is
a common example of what not to do but I’ll bet someone, somewhere,
has said ‘Gee, I wonder what this does?’. After a quick click-drag,
copy, paste; someone, somewhere, is having a bad day.
lol! that’s terrible! never thought of that.
Perhaps posts like this should have a mandatory disclosure:
The code snippets you see here were constructed by trained
professionals. Do NOT try these snippets at home.
Ugh. I get shivers just seeing this sort of thing in ‘print’. It is
a common example of what not to do but I’ll bet someone, somewhere,
has said ‘Gee, I wonder what this does?’. After a quick click-drag,
copy, paste; someone, somewhere, is having a bad day.
Perhaps posts like this should have a mandatory disclosure:
The code snippets you see here were constructed by trained
professionals. Do NOT try these snippets at home.
Ugh. I get shivers just seeing this sort of thing in ‘print’. It is
a common example of what not to do but I’ll bet someone, somewhere,
has said ‘Gee, I wonder what this does?’. After a quick click-drag,
copy, paste; someone, somewhere, is having a bad day.
The good news is that it’s probable that you won’t hear from that
person for…well, probably at least a couple of days before the
system is up and working again.
Ugh. I get shivers just seeing this sort of thing in ‘print’. It is
a common example of what not to do but I’ll bet someone, somewhere,
has said ‘Gee, I wonder what this does?’. After a quick click-drag,
copy, paste; someone, somewhere, is having a bad day.
The good news is that it’s probable that you won’t hear from that
person for…well, probably at least a couple of days before the
system is up and working again.
that reminds me of a presentation on drb i did once: we set up a mini
cluster
with everyones computer feeding from a tuplespace. then i submitted the
job
that reminds me of a presentation on drb i did once: we set up a mini cluster
with everyones computer feeding from a tuplespace. then i submitted the job
that reminds me of a presentation on drb i did once: we set up a
mini cluster
with everyones computer feeding from a tuplespace. then i
submitted the job