template.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. class CustomWizard::Template
  2. attr_reader :id,
  3. :name,
  4. :steps,
  5. :background,
  6. :save_submissions,
  7. :multiple_submissions,
  8. :prompt_completion,
  9. :min_trust,
  10. :after_signup,
  11. :after_time,
  12. :after_time_scheduled,
  13. :required,
  14. :theme_id
  15. def initialize(data)
  16. data = data.is_a?(String) ? ::JSON.parse(data) : data
  17. return nil if data.blank?
  18. @id = data['id']
  19. @name = data['name']
  20. @steps = data['steps']
  21. @background = data['background']
  22. @save_submissions = data['save_submissions'] || false
  23. @multiple_submissions = data['multiple_submissions'] || false
  24. @prompt_completion = data['prompt_completion'] || false
  25. @min_trust = data['min_trust'] || 0
  26. @after_signup = data['after_signup']
  27. @after_time = data['after_time']
  28. @after_time_scheduled = data['after_time_scheduled']
  29. @required = data['required'] || false
  30. @theme_id = data['theme_id']
  31. if data['theme']
  32. theme = Theme.find_by(name: data['theme'])
  33. @theme_id = theme.id if theme
  34. end
  35. end
  36. end