Skip to content

Instantly share code, notes, and snippets.

@shunsugai
Created June 4, 2012 13:20
Show Gist options
  • Save shunsugai/2868330 to your computer and use it in GitHub Desktop.
Save shunsugai/2868330 to your computer and use it in GitHub Desktop.
ClassMacro2
class Bar
class << self
def self.bar(method)
define_method(method) do
puts "Bar.#{method} called."
end
end
bar :foo
bar :baz
end
end
Bar.foo #=> Bar.foo called.
Bar.baz #=> Bar.baz called.
class Baz
class << self
class << self
def baz(method)
define_method(method) do
puts "Baz.#{method} called."
end
end
end
baz :foo
baz :bar
end
end
Baz.foo #=> Baz.foo called.
Baz.bar #=> Baz.bar called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment