Skip to content

Instantly share code, notes, and snippets.

@pinzolo
Created October 29, 2012 03:15
Show Gist options
  • Save pinzolo/3971278 to your computer and use it in GitHub Desktop.
Save pinzolo/3971278 to your computer and use it in GitHub Desktop.
include 時にクラスメソッドの alias を定義する
module Foo
def self.included(base)
class << base
alias_method :baz, :bar
end
end
end
class Bar
def self.bar
"bar"
end
end
class Baz < Bar
include Foo
end
p Baz.bar
# => "bar"
p Baz.baz
# => "bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment