Class: AgendrixTimeEntryResolver
- Inherits:
-
Object
- Object
- AgendrixTimeEntryResolver
- Defined in:
- app/resolver/agendrix_time_entry_resolver.rb
Defined Under Namespace
Classes: Actions
Constant Summary collapse
- USER_NAME =
'SYSTEM'
Instance Attribute Summary collapse
-
#company_id ⇒ Object
readonly
Returns the value of attribute company_id.
-
#employee_id ⇒ Object
readonly
Returns the value of attribute employee_id.
-
#employee_role_id ⇒ Object
readonly
Returns the value of attribute employee_role_id.
-
#time_entry ⇒ Object
readonly
Returns the value of attribute time_entry.
Instance Method Summary collapse
-
#initialize(company_id:, employee_id:, employee_role_id:, time_entry:) ⇒ AgendrixTimeEntryResolver
constructor
A new instance of AgendrixTimeEntryResolver.
- #resolve ⇒ Object
Constructor Details
#initialize(company_id:, employee_id:, employee_role_id:, time_entry:) ⇒ AgendrixTimeEntryResolver
Returns a new instance of AgendrixTimeEntryResolver.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/resolver/agendrix_time_entry_resolver.rb', line 14 def initialize( company_id:, employee_id:, employee_role_id:, time_entry: ) @company_id = company_id @employee_id = employee_id @employee_role_id = employee_role_id @time_entry = time_entry end |
Instance Attribute Details
#company_id ⇒ Object (readonly)
Returns the value of attribute company_id.
12 13 14 |
# File 'app/resolver/agendrix_time_entry_resolver.rb', line 12 def company_id @company_id end |
#employee_id ⇒ Object (readonly)
Returns the value of attribute employee_id.
12 13 14 |
# File 'app/resolver/agendrix_time_entry_resolver.rb', line 12 def employee_id @employee_id end |
#employee_role_id ⇒ Object (readonly)
Returns the value of attribute employee_role_id.
12 13 14 |
# File 'app/resolver/agendrix_time_entry_resolver.rb', line 12 def employee_role_id @employee_role_id end |
#time_entry ⇒ Object (readonly)
Returns the value of attribute time_entry.
12 13 14 |
# File 'app/resolver/agendrix_time_entry_resolver.rb', line 12 def time_entry @time_entry end |
Instance Method Details
#resolve ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/resolver/agendrix_time_entry_resolver.rb', line 26 def resolve ActiveRecord::Base.transaction do if find_integrated_timesheet update_timesheet { action: Actions::UPDATE, timesheet: @employee_timesheet, time_entry: time_entry } elsif find_timesheet_to_integrate integrate_timesheet update_timesheet { action: Actions::INTEGRATE, timesheet: @employee_timesheet, time_entry: time_entry } elsif create_timesheet integrate_timesheet { action: Actions::CREATE, timesheet: @employee_timesheet, time_entry: time_entry } end end rescue StandardError => e Rails.logger.error "Failed to resolve Agendrix time_entry: #{e.}, time_entry: #{time_entry}" raise e end |