Sha256: cad82a65f28e35b4ee4afdfded1c0fbe6aeebe3751c8363cbfede51ce4dc6c4a

Contents?: true

Size: 768 Bytes

Versions: 232

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

class Module
  # A module may or may not have a name.
  #
  #   module M; end
  #   M.name # => "M"
  #
  #   m = Module.new
  #   m.name # => nil
  #
  # +anonymous?+ method returns true if module does not have a name, false otherwise:
  #
  #   Module.new.anonymous? # => true
  #
  #   module M; end
  #   M.anonymous?          # => false
  #
  # A module gets a name when it is first assigned to a constant. Either
  # via the +module+ or +class+ keyword or by an explicit assignment:
  #
  #   m = Module.new # creates an anonymous module
  #   m.anonymous?   # => true
  #   M = m          # m gets a name here as a side-effect
  #   m.name         # => "M"
  #   m.anonymous?   # => false
  def anonymous?
    name.nil?
  end
end

Version data entries

232 entries across 217 versions & 27 rubygems

Version Path
activesupport-7.1.3.4 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.0.8.4 lib/active_support/core_ext/module/anonymous.rb
activesupport-6.1.7.8 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.2.0.beta1 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.3.2 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.3.1 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.0.8.1 lib/active_support/core_ext/module/anonymous.rb
activesupport-6.1.7.7 lib/active_support/core_ext/module/anonymous.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/activesupport-7.1.3/lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.3 lib/active_support/core_ext/module/anonymous.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/core_ext/module/anonymous.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activesupport-7.0.2.3/lib/active_support/core_ext/module/anonymous.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activesupport-7.0.3.1/lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.2 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.1 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.0 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.0.rc2 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.0.rc1 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.1.0.beta1 lib/active_support/core_ext/module/anonymous.rb
activesupport-7.0.8 lib/active_support/core_ext/module/anonymous.rb