Sha256: 139c536b5bdac4f24febeaea42e2c3f266e34b6ff0d12c39f36d551ec2d67457

Contents?: true

Size: 797 Bytes

Versions: 24

Compression:

Stored size: 797 Bytes

Contents

module Lita
  # A mixin for setting and getting a plugin's namespace.
  # @since 4.0.0
  module Namespace
    # Gets (and optionally sets) the namespace for a plugin. The namespace is generated from the
    # class's name by default.
    # @param value [String] If provided, sets the namespace of the plugin to the value.
    # @return [String] The namespace.
    # @raise [RuntimeError] If the plugin is an anonymous class, does not define +self.name+, and
    #   has not set a namespace manually.
    def namespace(value = nil)
      @namespace = value.to_s if value

      string_name = defined?(@namespace) ? @namespace : name

      if string_name
        Util.underscore(string_name.split("::").last)
      else
        raise I18n.t("lita.plugin.name_required")
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
lita-4.8.0 lib/lita/namespace.rb
lita-4.8.0.beta1 lib/lita/namespace.rb
lita-4.7.1 lib/lita/namespace.rb
lita-4.7.0 lib/lita/namespace.rb
lita-4.6.1 lib/lita/namespace.rb
lita-4.6.0 lib/lita/namespace.rb
lita-4.5.0 lib/lita/namespace.rb
lita-4.4.3 lib/lita/namespace.rb
lita-4.4.2 lib/lita/namespace.rb
lita-4.4.1 lib/lita/namespace.rb
lita-4.4.0 lib/lita/namespace.rb
lita-4.3.2 lib/lita/namespace.rb
lita-4.3.1 lib/lita/namespace.rb
lita-4.3.0 lib/lita/namespace.rb
lita-4.2.1 lib/lita/namespace.rb
lita-4.2.0 lib/lita/namespace.rb
lita-4.1.0 lib/lita/namespace.rb
lita-4.0.4 lib/lita/namespace.rb
lita-4.0.3 lib/lita/namespace.rb
lita-4.0.2 lib/lita/namespace.rb