-
Notifications
You must be signed in to change notification settings - Fork 1
Home
trans edited this page Oct 23, 2011
·
8 revisions
Parametric Mixins makes it easy to parameterize mixin modules.
module MyMixin
include Paramix::Parametric
parameterized do |params|
define_method :params do
params
end
end
def hello
puts "Hello from #{params[:name]}!"
end
end
class MyClass
include MyMixin[:name => 'Ruby']
end
m = MyClass.new
m.hello #=> 'Hello from Ruby!'