Skip to content

Instantly share code, notes, and snippets.

@dstarh
Last active December 11, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstarh/4525095 to your computer and use it in GitHub Desktop.
Save dstarh/4525095 to your computer and use it in GitHub Desktop.
class heirarchy
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