Skip to content

Instantly share code, notes, and snippets.

/gist:102816

Created Apr 27, 2009
Embed
What would you like to do?
module ActsAsDuck
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_duck(*args)
options = args.extract_options!
class_name = options[:name] || self.class.to_s + "Duck" # <-- problem here: self.class always is "Class"
module_eval(<<-EVAL, __FILE__, __LINE__)
class #{class_name}
def quack; puts "quack"; end
end
EVAL
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.