Edited at

Rubyでクラスメソッドの定義方法色々

More than 5 years have passed since last update.

今まではdef self.hogeって書いてたけど,class << self ...の方がまとまって見通しが良さそう.

class A

def A.class_method_one; end

def self.class_method_two; end

class << A
def class_method_three; end
end

class << self
def class_method_four; end
end
end

def A.class_method_five; end

class << A
def class_method_six; end
end