Skip to content

Instantly share code, notes, and snippets.

@moro
Created May 17, 2012 02:22
Show Gist options
  • Save moro/2715731 to your computer and use it in GitHub Desktop.
Save moro/2715731 to your computer and use it in GitHub Desktop.
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