# using method missing to reduce the code in ruby

I have a set of Class methods which is :

class << self
def increment_value
self.first.increment_value
end

def max_work_hours_per_day
self.first.max_work_hours_per_day
end

def fast_completion_day
self.first.fast_completion_day
end

def super_fast_completion_day
self.first.super_fast_completion_day
end

def ludicrous_completion_day
self.first.ludicrous_completion_day
end

def budget_completion_day
self.first.budget_completion_day
end
end


Since all the methods call self.first.atttibute where attribute is the same name as function name. I think we can reduce this to a single method. Something like method_missing is there in Ruby , but since I am not very good at meta programming , I am seeking advise here.

• This and this look like reasonabl nice ways to handle delegation in Ruby. – hobbs Aug 20 '11 at 4:38

class << self