class Pendulum::Command::Apply

Attributes

client[RW]
dry_run[RW]
force[RW]

Public Class Methods

new(client, from, to, dry_run=false, force=false, color=false) click to toggle source
# File lib/pendulum/command/apply.rb, line 5
def initialize(client, from, to, dry_run=false, force=false, color=false)
  @schedules = matched_schedules(client, from, to, dry_run, force, color)
end

Public Instance Methods

execute() click to toggle source
# File lib/pendulum/command/apply.rb, line 9
def execute
  @schedules.each{|s| s.apply }
end

Private Instance Methods

matched_schedules(client, from, to, dry_run, force, color) click to toggle source
# File lib/pendulum/command/apply.rb, line 15
def matched_schedules(client, from, to, dry_run, force, color)
  # create or update
  schedules = to.map do |schedule|
    Schedule.new(
      client,
      from.find{|f| f.name == schedule.name},
      schedule,
      dry_run,
      force,
      color
    )
  end

  # delete
  from.reject{|f| to.any?{|t| t.name == f.name}}.each do |schedule|
    schedules << Schedule.new(client, schedule, nil, dry_run, force, color)
  end
  schedules
end