by DotNetNerd
29. June 2010 19:39
This will probably be one of the shortest blogposts I'll ever write, and probably the one with the least amount of code - besides an occational rant. The reason is that like pictures sometimes say more than a 1000 words, so does elegant code.
module MyModule
class MyClass
def write_stuff text
puts text
end
end
end
m = MyModule::MyClass.new
actions = {:write_stuff => "Hello action packed world!"}
actions.each {|key, value| m.method(key).call(value) }
It might just be me who is weird - but I think this way of doing eg. a strategy pattern is pretty cool.