Skip to content

Instantly share code, notes, and snippets.

@marioaquino
Last active December 19, 2015 10:09
Show Gist options
  • Save marioaquino/5938584 to your computer and use it in GitHub Desktop.
Save marioaquino/5938584 to your computer and use it in GitHub Desktop.
The Pilotable proxy to the Drone (uses Forwardable to achieve ISP)
require 'forwardable'
class Pilotable
extend Forwardable
def_delegators :@aircraft, :take_off, :land, :fly_to
def initialize(aircraft)
@aircraft = aircraft
end
end
client_of_drone = Pilotable.new(Drone.new)
client_of_drone.take_off # works
client_of_drone.fly_to 10, 201, 20 # works
client_of_drone.launch_missiles_at 10, 201, 0 #(NoMethodError): undefined method `launch_missiles_at'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment