Class: TermsOfUse::Acceptor
- Inherits:
-
Object
- Object
- TermsOfUse::Acceptor
- Includes:
- ActiveModel::Validations
- Defined in:
- app/services/terms_of_use/acceptor.rb
Instance Attribute Summary collapse
-
#icn ⇒ Object
readonly
Returns the value of attribute icn.
-
#sync ⇒ Object
readonly
Returns the value of attribute sync.
-
#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:, sync: false) ⇒ Acceptor
constructor
A new instance of Acceptor.
- #log_and_raise_acceptor_error(error) ⇒ Object private
- #perform! ⇒ Object
- #terms_of_use_agreement ⇒ Object private
- #update_sign_up_service ⇒ Object private
Constructor Details
#initialize(user_account:, version:, sync: false) ⇒ Acceptor
Returns a new instance of Acceptor.
14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/terms_of_use/acceptor.rb', line 14 def initialize(user_account:, version:, sync: false) @user_account = user_account @version = version @sync = sync @icn = user_account&.icn validate! rescue ActiveModel::ValidationError => e log_and_raise_acceptor_error(e) end |
Instance Attribute Details
#icn ⇒ Object (readonly)
Returns the value of attribute icn.
10 11 12 |
# File 'app/services/terms_of_use/acceptor.rb', line 10 def icn @icn end |
#sync ⇒ Object (readonly)
Returns the value of attribute sync.
10 11 12 |
# File 'app/services/terms_of_use/acceptor.rb', line 10 def sync @sync end |
#user_account ⇒ Object (readonly)
Returns the value of attribute user_account.
10 11 12 |
# File 'app/services/terms_of_use/acceptor.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/acceptor.rb', line 10 def version @version end |
Instance Method Details
#log_and_raise_acceptor_error(error) ⇒ Object (private)
47 48 49 50 |
# File 'app/services/terms_of_use/acceptor.rb', line 47 def log_and_raise_acceptor_error(error) Rails.logger.error("[TermsOfUse] [Acceptor] Error: #{error.}", { user_account_id: user_account&.id }) raise Errors::AcceptorError, error. end |
#perform! ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/terms_of_use/acceptor.rb', line 25 def perform! terms_of_use_agreement.accepted! update_sign_up_service Logger.new(terms_of_use_agreement:).perform terms_of_use_agreement rescue ActiveRecord::RecordInvalid, StandardError => e log_and_raise_acceptor_error(e) end |
#terms_of_use_agreement ⇒ Object (private)
38 39 40 |
# File 'app/services/terms_of_use/acceptor.rb', line 38 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)
42 43 44 45 |
# File 'app/services/terms_of_use/acceptor.rb', line 42 def update_sign_up_service Rails.logger.info('[TermsOfUse] [Acceptor] update_sign_up_service', { icn: }) SignUpServiceUpdaterJob.set(sync:).perform_async(user_account.id, version) end |