Michael de Silva's Blog

Software Engineer. Rubyist and Roboticist.

Michael de Silva's Blog

Software Engineer. Rubyist and Roboticist.

On Holiday...!

I don't always go on holiday, but when I do

class Resource < Struct.new(:employee)
  define_method(:enable_vacation) { "Whoo! Employee '#{employee.handle}' is on holiday!!"}
end

Resource.new(
  Object.new.instance_eval { self.class.send(:define_method, :handle, ->{'@bsodmike'}) }
).enable_vacation

# => "Whoo! Employee '@bsodmike' is on holiday!!"
comments powered by Disqus