Declaring class methods in class_methods or included

Viewed 460
require 'active_support/concern'

module M
  extend ActiveSupport::Concern

  included do
    def self.b
      puts 'b'
    end
  end

  class_methods do
    def a
      puts 'a'
    end
  end
end

class H
  include M
end

Though class_methods is the standard way to define class methods in ActiveSupport::Concern, I do find a few examples where people declare class methods in included by using self.

Both works, so are there edgecases if class methods are defined inside included?

0 Answers
Related