Created
October 29, 2012 03:15
-
-
Save pinzolo/3971278 to your computer and use it in GitHub Desktop.
include 時にクラスメソッドの alias を定義する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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