Class: Flexite::Diff::ApplyService
- Inherits:
-
Object
- Object
- Flexite::Diff::ApplyService
- Defined in:
- app/services/flexite/diff/apply_service.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(stage, checksum) ⇒ ApplyService
constructor
A new instance of ApplyService.
Constructor Details
#initialize(stage, checksum) ⇒ ApplyService
Returns a new instance of ApplyService.
4 5 6 7 |
# File 'app/services/flexite/diff/apply_service.rb', line 4 def initialize(stage, checksum) @stage = stage @checksum = checksum end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/flexite/diff/apply_service.rb', line 9 def call diffs = Flexite.cache.read("#{Flexite.state_digest}-#{@checksum}-#{@stage}-diffs") if diffs.blank? Flexite.cache.delete_matched(/-#{@stage}-hashdiffs/) return { error: 'Difference is inconsistent', code: 400 } end Config.transaction(requires_new: true) do Entry.transaction do handle_delete(diffs[:-]) handle_add(diffs[:+]) handle_change(diffs[:~]) end end { message: 'Difference was applied', code: 200 } rescue => exc { error: exc., code: 500 } end |