module ActiveSupport::Concern
def class_methods(&class_methods_module_definition)
Buzz.foo # => "foo"
end
include Example
class Buzz
end
end
def bar; puts 'bar'; end
private
def foo; puts 'foo'; end
class_methods do
extend ActiveSupport::Concern
module Example
You can define private class methods as well.
Define class methods from given block.
def class_methods(&class_methods_module_definition) mod = const_defined?(:ClassMethods, false) ? const_get(:ClassMethods) : const_set(:ClassMethods, Module.new) mod.module_eval(&class_methods_module_definition) end