step_updater.rb 684 B

12345678910111213141516171819202122232425262728293031
  1. class CustomWizard::StepUpdater
  2. include ActiveModel::Model
  3. attr_accessor :refresh_required, :fields, :result, :step
  4. def initialize(current_user, wizard, step, fields)
  5. @current_user = current_user
  6. @wizard = wizard
  7. @step = step
  8. @refresh_required = false
  9. @fields = fields
  10. end
  11. def update
  12. @step.updater.call(self) if @step.present? && @step.updater.present?
  13. if success?
  14. UserHistory.create(action: UserHistory.actions[:custom_wizard_step],
  15. context: @wizard.id,
  16. subject: @step.id)
  17. end
  18. end
  19. def success?
  20. @errors.blank?
  21. end
  22. def refresh_required?
  23. @refresh_required
  24. end
  25. end