Skip to content

Instantly share code, notes, and snippets.

@markson
Created May 28, 2013 21:55
Show Gist options
  • Save markson/5666484 to your computer and use it in GitHub Desktop.
Save markson/5666484 to your computer and use it in GitHub Desktop.
composition
require 'pry'
class Car
attr_reader :model, :valve
attr_writer :passenger
def initialize(model, valve)
@model = model
@engine = Engine.new(valve)
end
def run
puts "wowowowo"
end
end
class Engine
def initialize(valve)
@valve = valve
end
end
class Passenger
def initialize(name)
@name = name
end
end
p = Passenger.new("Foo")
car = Car.new("9-3 convertible", 4)
car.passenger(p)
binding.pry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment