Class: DNSimple::Commands::UpdateRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/dnsimple/commands/update_record.rb

Instance Method Summary collapse

Instance Method Details

#execute(args, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dnsimple/commands/update_record.rb', line 4

def execute(args, options={})
  attributes = {}
  domain_name = args.shift
  id = args.shift
  args.each do |arg|
    name, value = arg.split(":")
    attributes[Record.resolve(name)] = value
  end

  domain = Domain.find(domain_name)
  record = Record.find(domain, id)
  attributes.each do |name, value|
    record.send("#{name}=", value)
  end
  record.save
  puts "Updated record #{record.fqdn} (id: #{record.id})"
end