Class: PostyClient::Command::DomainAliasCommand

Inherits:
Thor
  • Object
show all
Includes:
FinderConcerns, Resources
Defined in:
lib/posty_client/command/domain_alias_command.rb

Instance Method Summary collapse

Methods included from FinderConcerns

#find_domain_alias_by_domain_and_name, #find_domain_by_name, #find_user_alias_by_email_and_name, #find_user_by_email, #user_and_domain_from_email

Instance Method Details

#add(domain_name, alias_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/posty_client/command/domain_alias_command.rb', line 17

def add(domain_name, alias_name)
  domain = find_domain_by_name(domain_name)

  ali = DomainAlias.new(domain, alias_name)

  unless ali.save
    say("#{alias_name} save failed: #{ali.errors}", :red)
    exit 1
  end
end

#delete(domain_name, name) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/posty_client/command/domain_alias_command.rb', line 29

def delete(domain_name, name)
  ali = find_domain_alias_by_domain_and_name(domain_name, name)
  if ali.new_resource?
    say("#{name} unknown", :red)
    exit 1
  end

  unless ali.delete
    say("#{name} delete failed: #{ali.errors}", :red)
    exit 1
  end
end

#list(domain) ⇒ Object



10
11
12
13
14
# File 'lib/posty_client/command/domain_alias_command.rb', line 10

def list(domain)
  domain = find_domain_by_name(domain)
  domain_aliases = domain.aliases
  puts domain_aliases.map(&:name)
end