Class: TermsOfUse::Acceptor

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/services/terms_of_use/acceptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_account:, common_name:, version:) ⇒ Acceptor

Returns a new instance of Acceptor.



13
14
15
16
17
18
19
20
21
22
# File 'app/services/terms_of_use/acceptor.rb', line 13

def initialize(user_account:, common_name:, version:)
  @user_account = 
  @common_name = common_name
  @version = version
  @icn = &.icn

  validate!
rescue ActiveModel::ValidationError => e
  log_and_raise_acceptor_error(e)
end

Instance Attribute Details

#common_nameObject (readonly)

Returns the value of attribute common_name.



9
10
11
# File 'app/services/terms_of_use/acceptor.rb', line 9

def common_name
  @common_name
end

#icnObject (readonly)

Returns the value of attribute icn.



9
10
11
# File 'app/services/terms_of_use/acceptor.rb', line 9

def icn
  @icn
end

#user_accountObject (readonly)

Returns the value of attribute user_account.



9
10
11
# File 'app/services/terms_of_use/acceptor.rb', line 9

def 
  @user_account
end

#versionObject (readonly)

Returns the value of attribute version.



9
10
11
# File 'app/services/terms_of_use/acceptor.rb', line 9

def version
  @version
end

Instance Method Details

#perform!Object



24
25
26
27
28
29
30
31
32
33
# File 'app/services/terms_of_use/acceptor.rb', line 24

def perform!
  terms_of_use_agreement.accepted!
  

  Logger.new(terms_of_use_agreement:).perform

  terms_of_use_agreement
rescue ActiveRecord::RecordInvalid => e
  log_and_raise_acceptor_error(e)
end