Module: Lita::Namespace

Included in:
Adapter
Defined in:
lib/lita/namespace.rb

Overview

A mixin for setting and getting a plugin's namespace.

Since:

  • 4.0.0

Instance Method Summary collapse

Instance Method Details

#namespace(value = nil) ⇒ String

Gets (and optionally sets) the namespace for a plugin. The namespace is generated from the class's name by default.

Raises:

  • (RuntimeError)

    If the plugin is an anonymous class, does not define self.name, and has not set a namespace manually.

Since:

  • 4.0.0


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lita/namespace.rb', line 11

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