Class: Lita::Handlers::UpdateTeam

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/update_team.rb

Constant Summary collapse

ATTRIBUTES_MAPPING =
{
  limit: :to_i,
  location: :to_s,
  time: :to_s,
  icon: :to_s
}.freeze

Instance Method Summary collapse

Instance Method Details

#update(response) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/lita/handlers/update_team.rb', line 26

def update(response)
  team_name = response.match_data[1]
  if team = get_team(team_name)
    attribute = response.match_data[2].to_sym
    value = parse_attribute_value(attribute, response.match_data[3])
    team[attribute] = value
    save_team(team)
    response.reply(
      render_template(:team_updated,
                      team_name: team_name,
                      attribute: attribute,
                      value: value
                     )
    )
  else
    response.reply(
      render_template(:team_not_found, team_name: team_name)
    )
  end
end