Class: Giticious::Service::User
- Inherits:
-
Object
- Object
- Giticious::Service::User
- Defined in:
- lib/giticious/service/user.rb
Instance Method Summary collapse
- #create(username) ⇒ Object
- #delete_by_username(username) ⇒ Object
- #exists?(username) ⇒ Boolean
- #list ⇒ Object
Instance Method Details
#create(username) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/giticious/service/user.rb', line 18 def create(username) if Giticious::Model::User.find_by_username(username).nil? == false raise ArgumentError, "a user with this name does already exist" end user = Giticious::Model::User.new user.username = username user.save! end |
#delete_by_username(username) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/giticious/service/user.rb', line 29 def delete_by_username(username) user = Giticious::Model::User.find_by_username(username) if user.nil? raise ArgumentError, "The selected user does not exist" end Giticious::Model::Permission.where(user_id: user.id).delete_all user.destroy! end |