Class: PostyClient::Command::UserAliasCommand
- Inherits:
-
Thor
- Object
- Thor
- PostyClient::Command::UserAliasCommand
show all
- Includes:
- FinderConcerns, Resources
- Defined in:
- lib/posty_client/command/user_alias_command.rb
Instance Method Summary
collapse
#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(email, alias_name) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/posty_client/command/user_alias_command.rb', line 17
def add(email, alias_name)
user = find_user_by_email(email)
ali = UserAlias.new(user, alias_name)
unless ali.save
say("#{alias_name} save failed: #{ali.errors}", :red)
exit 1
end
end
|
#delete(email, alias_name) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/posty_client/command/user_alias_command.rb', line 29
def delete(email, alias_name)
ali = find_user_alias_by_email_and_name(email, alias_name)
if ali.new_resource?
say("#{alias_name} unknown", :red)
exit 1
end
unless ali.delete
say("#{alias_name} delete failed: #{ali.errors}", :red)
exit 1
end
end
|
#list(name) ⇒ Object
10
11
12
13
14
|
# File 'lib/posty_client/command/user_alias_command.rb', line 10
def list(name)
user = find_user_by_email(name)
users = user.aliases
puts users.map(&:name)
end
|