Class: TermsOfUse::Decliner
- Inherits:
-
Object
- Object
- TermsOfUse::Decliner
- Includes:
- ActiveModel::Validations
- Defined in:
- app/services/terms_of_use/decliner.rb
Instance Attribute Summary collapse
-
#icn ⇒ Object
readonly
Returns the value of attribute icn.
-
#user_account ⇒ Object
readonly
Returns the value of attribute user_account.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(user_account:, version:) ⇒ Decliner
constructor
A new instance of Decliner.
- #log_and_raise_decliner_error(error) ⇒ Object private
- #perform! ⇒ Object
- #terms_of_use_agreement ⇒ Object private
- #update_sign_up_service ⇒ Object private
Constructor Details
#initialize(user_account:, version:) ⇒ Decliner
Returns a new instance of Decliner.
14 15 16 17 18 19 20 21 22 |
# File 'app/services/terms_of_use/decliner.rb', line 14 def initialize(user_account:, version:) @user_account = user_account @icn = user_account&.icn @version = version validate! rescue ActiveModel::ValidationError => e log_and_raise_decliner_error(e) end |
Instance Attribute Details
#icn ⇒ Object (readonly)
Returns the value of attribute icn.
10 11 12 |
# File 'app/services/terms_of_use/decliner.rb', line 10 def icn @icn end |
#user_account ⇒ Object (readonly)
Returns the value of attribute user_account.
10 11 12 |
# File 'app/services/terms_of_use/decliner.rb', line 10 def user_account @user_account end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'app/services/terms_of_use/decliner.rb', line 10 def version @version end |
Instance Method Details
#log_and_raise_decliner_error(error) ⇒ Object (private)
46 47 48 49 |
# File 'app/services/terms_of_use/decliner.rb', line 46 def log_and_raise_decliner_error(error) Rails.logger.error("[TermsOfUse] [Decliner] Error: #{error.}", { user_account_id: user_account&.id }) raise Errors::DeclinerError, error. end |
#perform! ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/terms_of_use/decliner.rb', line 24 def perform! terms_of_use_agreement.declined! update_sign_up_service Logger.new(terms_of_use_agreement:).perform terms_of_use_agreement rescue ActiveRecord::RecordInvalid => e log_and_raise_decliner_error(e) end |
#terms_of_use_agreement ⇒ Object (private)
37 38 39 |
# File 'app/services/terms_of_use/decliner.rb', line 37 def terms_of_use_agreement @terms_of_use_agreement ||= user_account.terms_of_use_agreements.new(agreement_version: version) end |
#update_sign_up_service ⇒ Object (private)
41 42 43 44 |
# File 'app/services/terms_of_use/decliner.rb', line 41 def update_sign_up_service Rails.logger.info('[TermsOfUse] [Decliner] update_sign_up_service', { icn: }) SignUpServiceUpdaterJob.perform_async(user_account.id, version) end |