CantFlyException, "Wing is wounded" end end class Wing def fly puts "If only I was an African swallow, I could carry a coconut." end end class Dove def initialize(wing) @wing = wing end def fly @wing.fly end end }We have Forwardable in the STD lib for that
only I was an African swallow, I could carry a coconut. broken_wing = WoundedWing.new dove_2 = Dove.new(broken_wing) dove_2.fly # => Wing is wounded (CantFlyException)
different animals, includin birds • You can exchan e the wounded win with a healthy one when it ets cured • You can do win -size and wei ht specific calculations for speed (yep, yep)
paper from ’87 that unites the results of three papers • It‘s written by the authors of the papers themselves: Henry Liebermann, Lynn Andrea Stein and David Un ar • … and it ends with the sentence: “this a reement shall henceforth be known as the TREATY OF ORLANDO.” :)
patterns by the time an object is created • Dynamic systems permit determination of sharin patterns durin runtime, when an object actually receives a messa e
for the method definition • Per object inheritance is much easier to mock • You can also chan e the dele ation tar et at runtime (when the win ets cured) • Therefore Ruby‘s Forwardable is the better inheritance mechanism in Ruby
reimplement all hooks it needs, you have a lot of code duplication • But you still have the same problems with testin etc. • Keep the herita e small (Lookin at you, ActiveRecord)