Class: Lita::Handlers::Authorization

Inherits:
Lita::Handler show all
Defined in:
lib/lita/handlers/authorization.rb

Overview

Provides a chat interface for administering authorization groups.

Instance Method Summary collapse

Methods included from Lita::Handler::ChatRouter

#dispatch, #dispatch_to_route, extended, #route, #routes

Methods included from Lita::Handler::HTTPRouter

extended, #http, #http_routes

Methods included from Lita::Handler::EventRouter

#event_subscriptions_for, extended, #on, #trigger

Instance Method Details

#add(response) ⇒ void

This method returns an undefined value.

Adds a user to an authorization group.

Parameters:



27
28
29
# File 'lib/lita/handlers/authorization.rb', line 27

def add(response)
  toggle_membership(response, :add_user_to_group, "user_added", "user_already_in")
end

#list(response) ⇒ void

This method returns an undefined value.

Lists all authorization groups (or only the specified group) and the names of their members.

Parameters:



42
43
44
45
46
47
48
49
50
# File 'lib/lita/handlers/authorization.rb', line 42

def list(response)
  requested_group = response.args[1]
  output = get_groups_list(response.args[1])
  if output.empty?
    response.reply(empty_state_for_list(requested_group))
  else
    response.reply(output.join("\n"))
  end
end

#remove(response) ⇒ void

This method returns an undefined value.

Removes a user from an authorization group.

Parameters:



34
35
36
# File 'lib/lita/handlers/authorization.rb', line 34

def remove(response)
  toggle_membership(response, :remove_user_from_group, "user_removed", "user_not_in")
end