Created
May 17, 2012 02:22
-
-
Save moro/2715731 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class MyModule < Module | |
attr_reader :description | |
def initialize(description, *args, &b) | |
@description = description | |
super(*args, &b) | |
end | |
end | |
class Foo | |
include MyModule.new('has SPECIAL ivar') {|mod| | |
define_method(:description) { mod.description } | |
def greet | |
"Hi, I'm a special module that #{description.downcase}" | |
end | |
} | |
end | |
p Foo.new.greet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment