view · edit · sidebar · attach · print · history

Alias Method Alternative

<< Aliasing | Index | Array >>

 http://blog.jayfields.com/2006/12/ruby-alias-method-alternative.html

Code

 class ClockRadio
  on = self.instance_method(:on!)

  define_method(:on!) do
    on.bind(self).call
    @display_time = true
  end

  def display_time?
    @display_time
  end
 end
view · edit · sidebar · attach · print · history
Page last modified on April 07, 2011, at 11:34 AM