こんな感じ
This file contains 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
class Foo | |
private_class_method def self.common_method(*syms) | |
syms.each do |sym| | |
define_method sym do | |
puts sym | |
end | |
end | |
end | |
common_method :murajun, :murajun1978 | |
end | |
Foo.new.murajun # => murajun | |
Foo.new.murajun1978 # => murajun1978 |
共通部分をまとめるのに便利
( ̄(エ) ̄)彡☆
0 件のコメント:
コメントを投稿