Skip to content

Instantly share code, notes, and snippets.

@atmos
Forked from jnunemaker/gist:412580
Created May 25, 2010 00:06
Show Gist options
  • Select an option

  • Save atmos/412585 to your computer and use it in GitHub Desktop.

Select an option

Save atmos/412585 to your computer and use it in GitHub Desktop.

Revisions

  1. atmos revised this gist May 25, 2010. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions gistfile1.builder
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,9 @@
    # and either way all the letters a, b, and c are
    # printed out (though not necessarily in that exact order)

    class TopLevel
    require 'pp'

    module Z
    def foo; end
    end

    @@ -23,14 +25,16 @@ module B
    end
    end

    class C < TopLevel
    class C
    include Z
    include A
    include B

    def foo
    super
    puts 'c'
    end

    end

    C.new.foo
  2. atmos revised this gist May 25, 2010. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions gistfile1.builder
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,10 @@
    # and either way all the letters a, b, and c are
    # printed out (though not necessarily in that exact order)

    class TopLevel
    def foo; end
    end

    module A
    def foo
    super
    @@ -19,7 +23,7 @@ module B
    end
    end

    class C
    class C < TopLevel
    include A
    include B

    @@ -29,4 +33,4 @@ class C
    end
    end

    C.new.foo
    C.new.foo
  3. @jnunemaker jnunemaker created this gist May 25, 2010.
    32 changes: 32 additions & 0 deletions gistfile1.builder
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    # What is the best way to get it to put out a, b, c
    # without erroring about the superclass. The module
    # inclusion order should not matter. In other words,
    # I should be able to include A then B or B then A
    # and either way all the letters a, b, and c are
    # printed out (though not necessarily in that exact order)

    module A
    def foo
    super
    puts 'a'
    end
    end

    module B
    def foo
    super
    puts 'b'
    end
    end

    class C
    include A
    include B

    def foo
    super
    puts 'c'
    end
    end

    C.new.foo