I have a set of Class methods which is :class << selfdef increment_value  self.first.increment_valueenddef max_work_hours_per_day  self.first.max_work_hours_per_dayenddef fast_completion_day  self.first.fast_completion_dayenddef super_fast_completion_day  self.first.super_fast_completion_dayenddef ludicrous_completion_day  self.first.ludicrous_completion_dayenddef budget_completion_day  self.first.budget_completion_dayendendSince 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.
using method missing to reduce the code in ruby
ruby;ruby on rails
Ruby already has a module which allows you to forward specific methods to a given object in its standard library: the Forwardable module.Using it you can write code like this:class << self  extend Forwardable  def_delegators :first, :increment_value, :max_work_hours_per_day #...endI think spelling out the methods you want to forward like this is preferable to simply forwarding everything as it won't accidentally forward something you don't want to forward. It also does not affect the error message when calling a method that does not exist.