Last active
December 11, 2015 01:39
-
-
Save dstarh/4525095 to your computer and use it in GitHub Desktop.
class heirarchy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module X | |
def initialize(params ={}) | |
puts 'setting params in module x' | |
@foo = params[:foo] | |
end | |
end | |
module Y | |
def initialize(params ={}) | |
super if defined?(super) | |
puts 'setting params in module y' | |
@bar = params[:bar] | |
end | |
end | |
class A | |
include X | |
def initialize(params ={}) | |
super | |
puts 'setting params in abstract class' | |
@bat = params[:bat] | |
end | |
end | |
class B < A | |
include Y | |
def initialize(params ={}) | |
super | |
puts 'setting params in class B' | |
@baz = params[:baz] | |
end | |
end | |
class C | |
include X | |
include Y | |
def initialize(params ={}) | |
super | |
puts 'setting params in class c' | |
end | |
end | |
puts 'new b--------' | |
b = B.new | |
puts 'new c--------' | |
c = C.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment