method

class_methods

Importance_1
v6.1.3.1 - Show latest stable - 0 notes - Class: ActiveSupport::Concern
class_methods(&class_methods_module_definition) public

Define class methods from given block. You can define private class methods as well.

module Example
  extend ActiveSupport::Concern

  class_methods do
    def foo; puts 'foo'; end

    private
      def bar; puts 'bar'; end
  end
end

class Buzz
  include Example
end

Buzz.foo # => "foo"
Buzz.bar # => private method 'bar' called for Buzz:Class(NoMethodError)
Show source
Register or log in to add new notes.