0
0

More than 3 years have passed since last update.

【Rails】メモ: Concern内にプライベートクラスメソッドを書く

Posted at

ActiveSupport::Concernモジュール内にプライベートクラスメソッドを書く際に少し詰まったのでメモしておきます。
sample_class_methodはプライベートクラスメソッドとして扱うことが出来ます。

module Sample
  extend ActiveSupport::Concern

  included do
    private_class_method :sample_class_method
  end

  class_methods do
    def sample_class_method
      puts 'hello world!'
    end
  end

  private

  def private_instance_method
    puts 'hello world!'
  end
end
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0