Class: Users::RespondToTermsService
- Inherits:
-
Object
- Object
- Users::RespondToTermsService
- Defined in:
- app/services/users/respond_to_terms_service.rb
Instance Method Summary collapse
-
#execute(accepted:) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
-
#initialize(user, term) ⇒ RespondToTermsService
constructor
A new instance of RespondToTermsService.
Constructor Details
#initialize(user, term) ⇒ RespondToTermsService
Returns a new instance of RespondToTermsService.
5 6 7 8 |
# File 'app/services/users/respond_to_terms_service.rb', line 5 def initialize(user, term) @user = user @term = term end |
Instance Method Details
#execute(accepted:) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/users/respond_to_terms_service.rb', line 11 def execute(accepted:) agreement = @user.term_agreements.find_or_initialize_by(term: @term) agreement.accepted = accepted if agreement.save store_accepted_term(accepted) end agreement end |