Class: WorkCompareService
- Inherits:
-
Object
- Object
- WorkCompareService
- Defined in:
- app/services/work_compare_service.rb
Instance Attribute Summary collapse
-
#differences ⇒ Object
readonly
Returns the value of attribute differences.
Class Method Summary collapse
-
.update_work(work:, update_params:, current_user:) ⇒ Boolean
Updates a work with the parameters and logs any changes.
Instance Method Summary collapse
- #identical? ⇒ Boolean
-
#initialize(before, after) ⇒ WorkCompareService
constructor
A new instance of WorkCompareService.
Constructor Details
#initialize(before, after) ⇒ WorkCompareService
Returns a new instance of WorkCompareService.
24 25 26 27 28 29 |
# File 'app/services/work_compare_service.rb', line 24 def initialize(before, after) @before = before @after = after @differences = {} compare_works end |
Instance Attribute Details
#differences ⇒ Object (readonly)
Returns the value of attribute differences.
4 5 6 |
# File 'app/services/work_compare_service.rb', line 4 def differences @differences end |
Class Method Details
.update_work(work:, update_params:, current_user:) ⇒ Boolean
Updates a work with the parameters and logs any changes
12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/work_compare_service.rb', line 12 def update_work(work:, update_params:, current_user:) work_before = work.dup if work.update(update_params) work_compare = new(work_before, work) work.log_changes(work_compare, current_user.id) true else false end end |
Instance Method Details
#identical? ⇒ Boolean
31 32 33 |
# File 'app/services/work_compare_service.rb', line 31 def identical? @differences == {} end |