Module: ActiveSupport::Concern

Defined in:
lib/concerning/concern_class_methods.rb

Instance Method Summary collapse

Instance Method Details

#class_methods(&class_methods_module_definition) ⇒ Object

Provide a class_methods alternative to ClassMethods since defining a constant within a block doesn’t work as folks would expect.



4
5
6
7
8
9
10
# File 'lib/concerning/concern_class_methods.rb', line 4

def class_methods(&class_methods_module_definition)
  mod = const_defined?(:ClassMethods) ?
    const_get(:ClassMethods) :
    const_set(:ClassMethods, Module.new)

  mod.module_eval(&class_methods_module_definition)
end