Easing the Delegation Blues : Forwardable « Collections « Ruby






Easing the Delegation Blues


require 'forwardable'

class WriterDecorator
  extend Forwardable

  def_delegators :@real_writer, :write_line, :rewind, :pos, :close

  def initialize(real_writer)
   @real_writer = real_writer
  end

end

 








Related examples in the same category

1.extend Forwardable
2.extending Forwardable delegates to hash