Skip to content

Instantly share code, notes, and snippets.

@chrismo
Created June 8, 2015 22:24
Show Gist options
  • Select an option

  • Save chrismo/d43fcfe02e2baf7e71d1 to your computer and use it in GitHub Desktop.

Select an option

Save chrismo/d43fcfe02e2baf7e71d1 to your computer and use it in GitHub Desktop.

Revisions

  1. chrismo revised this gist Jun 8, 2015. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions super_modules
    Original file line number Diff line number Diff line change
    @@ -34,3 +34,9 @@ end
    puts BoatCar.new.vroom
    puts CarBoat.new.vroom
    puts EnhancedCar.new.vroom

    ###

    <car noise>
    <boat noise>
    <enhanced <car noise>>
  2. chrismo created this gist Jun 8, 2015.
    36 changes: 36 additions & 0 deletions super_modules
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    module Car
    def vroom
    '<car noise>'
    end
    end

    module Boat
    def vroom
    '<boat noise>'
    end
    end

    module Enhancer
    def vroom
    "<enhanced #{super}>"
    end
    end

    class CarBoat
    include Car
    include Boat
    end

    class BoatCar
    include Boat
    include Car
    end

    class EnhancedCar
    include Car
    include Enhancer
    end

    puts BoatCar.new.vroom
    puts CarBoat.new.vroom
    puts EnhancedCar.new.vroom