Can I define class methods with Module#concerning?

Viewed 1905

I'd like to define class method using Module#concerning (https://github.com/37signals/concerning - part of Rails 4.1). This would let me move modules that are used by a single class back into the class.

However, it seems that I can't define class methods. Given this:

class User < ActiveRecord::Base
  attr_accessible :name

  concerning :Programmers do
    module ClassMethods 
      def programmer?
        true
      end
    end
  end

  module Managers 
    extend ActiveSupport::Concern

    module ClassMethods
      def manager?
        true
      end
    end
  end

  include Managers
end

I would expect both these to work:

User.manager?
User.programmer?

But the second raises

NoMethodError: undefined method `programmer?' for #<Class:0x007f9641beafd0>

How can I define class methods using Module#concerning?

3 Answers
Related