Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Some
- def initialize(name)
- @name = name
- end
- def hello
- p "hello, #{@name}"
- end
- end
- def some_factory
- Some.new('bot')
- end
- module AnotherModule
- def goodbye
- p "goodbye, #{@name}"
- end
- end
- class Another < Some
- include AnotherModule
- end
- def another_factory(type)
- if type
- Another.new('master')
- else
- some = some_factory
- some.extend(AnotherModule)
- end
- end
- another_factory(false).hello
- another_factory(true).hello
Add Comment
Please, Sign In to add comment