step_updater.rb 743 B

1234567891011121314151617181920212223242526272829303132
  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. acting_user_id: @current_user.id,
  16. context: @wizard.id,
  17. subject: @step.id)
  18. end
  19. end
  20. def success?
  21. @errors.blank?
  22. end
  23. def refresh_required?
  24. @refresh_required
  25. end
  26. end