class Lita::Updates::Commands::ClearSchedule

Attributes

redis[R]
robot[R]
user[R]

Public Class Methods

call(robot, redis, user) click to toggle source
# File lib/lita/updates/commands/clear_schedule.rb, line 2
def self.call(robot, redis, user)
  new(robot, redis, user).call
end
new(robot, redis, user) click to toggle source
# File lib/lita/updates/commands/clear_schedule.rb, line 6
def initialize(robot, redis, user)
  @robot = robot
  @redis = redis
  @user  = user
end

Public Instance Methods

call() click to toggle source
# File lib/lita/updates/commands/clear_schedule.rb, line 12
def call
  schedule.delete user.mention_name

  redis.set "lita-updates:schedule", JSON.dump(schedule)

  Lita::Updates::Commands::GetSchedule.call robot, redis, user
end

Private Instance Methods

schedule() click to toggle source
# File lib/lita/updates/commands/clear_schedule.rb, line 24
def schedule
  @schedule ||= JSON.load schedule_raw
end
schedule_raw() click to toggle source
# File lib/lita/updates/commands/clear_schedule.rb, line 28
def schedule_raw
  raw = redis.get("lita-updates:schedule")
  return "{}" if raw.nil? || raw.empty?

  raw
end