Class: Achievements::DestroyService

Inherits:
Object
  • Object
show all
Defined in:
app/services/achievements/destroy_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user, achievement) ⇒ DestroyService

Returns a new instance of DestroyService.



7
8
9
10
# File 'app/services/achievements/destroy_service.rb', line 7

def initialize(current_user, achievement)
  @current_user = current_user
  @achievement = achievement
end

Instance Attribute Details

#achievementObject (readonly)

Returns the value of attribute achievement.



5
6
7
# File 'app/services/achievements/destroy_service.rb', line 5

def achievement
  @achievement
end

#current_userObject (readonly)

Returns the value of attribute current_user.



5
6
7
# File 'app/services/achievements/destroy_service.rb', line 5

def current_user
  @current_user
end

Instance Method Details

#executeObject



12
13
14
15
16
17
# File 'app/services/achievements/destroy_service.rb', line 12

def execute
  return error_no_permissions unless allowed?

  achievement.delete
  ServiceResponse.success(payload: achievement)
end