Class: PostyClient::Command::TransportCommand

Inherits:
Thor
  • Object
show all
Defined in:
lib/posty_client/command/transport_command.rb

Instance Method Summary collapse

Instance Method Details

#add(name, destination) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/posty_client/command/transport_command.rb', line 11

def add(name, destination)
  transport = PostyClient::Resources::Transport.new(name)
  transport.attributes['destination'] = destination
  
  unless transport.save
    say transport.errors.inspect, :red
    exit 1
  end
end

#delete(name) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/posty_client/command/transport_command.rb', line 33

def delete(name)
  if yes?("Delete #{name}?")
    transport = PostyClient::Resources::Transport.new(name)
    unless transport.delete
      say transport.errors.inspect, :red
      exit 1
    end
  end
end

#listObject



5
6
7
8
# File 'lib/posty_client/command/transport_command.rb', line 5

def list
  transports = PostyClient::Resources::Transport.all.map {|d| [d.name]}
  print_table(transports)
end

#rename(name, new_name) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/posty_client/command/transport_command.rb', line 22

def rename(name, new_name)
  transport = PostyClient::Resources::Transport.new(name)
  transport.attributes['name'] = new_name
  
  unless transport.save
    say transport.errors.inspect, :red
    exit 1
  end
end