Class: HyperKittenMeowCommand

Inherits:
Rails::Command::Base
  • Object
show all
Defined in:
lib/commands/hyper_kitten_meow_command.rb

Instance Method Summary collapse

Instance Method Details

#create_userObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/commands/hyper_kitten_meow_command.rb', line 5

def create_user
  require_application_and_environment!
  name = ask("What is your name?")
  email = ask("What is your email address?")
  password = ask("Please choose a password.", echo: false)
  say("\n")
  password_confirmation = ask("Please confirm your password.", echo: false)

  ::HyperKittenMeow::User.create!(
    name: name, email: email, password: password,
    password_confirmation: password_confirmation
  )
end

#delete_user(email) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/commands/hyper_kitten_meow_command.rb', line 31

def delete_user(email)
  require_application_and_environment!
  user = ::HyperKittenMeow::User.find_by_email(email)
  if user.destroy!
    say("Removed #{user.name}.")
  end
end

#list_usersObject



20
21
22
23
24
25
26
27
28
# File 'lib/commands/hyper_kitten_meow_command.rb', line 20

def list_users
  require_application_and_environment!
  users = ::HyperKittenMeow::User.all
  users = users.map do |user|
    [user.name, user.email]
  end
  say("HyperKitten users")
  print_table(users)
end