Class: InProgressForm
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- InProgressForm
- Defined in:
- app/models/in_progress_form.rb
Defined Under Namespace
Classes: CleanUUID
Constant Summary collapse
- RETURN_URL_SQL =
"CAST(metadata -> 'returnUrl' AS text)"
Instance Attribute Summary collapse
-
#real_user_uuid ⇒ Object
Returns the value of attribute real_user_uuid.
-
#skip_exipry_update ⇒ Object
Returns the value of attribute skip_exipry_update.
Class Method Summary collapse
Instance Method Summary collapse
- #data_and_metadata ⇒ Object
-
#expires_after ⇒ ActiveSupport::Duration
Determines an expiration duration based on the UI form_id.
- #metadata ⇒ Object
Methods inherited from ApplicationRecord
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Instance Attribute Details
#real_user_uuid ⇒ Object
Returns the value of attribute real_user_uuid.
16 17 18 |
# File 'app/models/in_progress_form.rb', line 16 def real_user_uuid @real_user_uuid end |
#skip_exipry_update ⇒ Object
Returns the value of attribute skip_exipry_update.
16 17 18 |
# File 'app/models/in_progress_form.rb', line 16 def skip_exipry_update @skip_exipry_update end |
Class Method Details
.for_user(user) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'app/models/in_progress_form.rb', line 54 def self.for_user(user) user_uuid_forms = InProgressForm.where(user_uuid: user.uuid) if user.user_account user_uuid_forms.or(InProgressForm.where(user_account: user.user_account)) else user_uuid_forms end end |
.form_for_user(form_id, user) ⇒ Object
48 49 50 51 52 |
# File 'app/models/in_progress_form.rb', line 48 def self.form_for_user(form_id, user) user_uuid_form = InProgressForm.find_by(form_id:, user_uuid: user.uuid) user_account_form = InProgressForm.find_by(form_id:, user_account: user.user_account) if user.user_account user_uuid_form || user_account_form end |
Instance Method Details
#data_and_metadata ⇒ Object
63 64 65 66 67 68 |
# File 'app/models/in_progress_form.rb', line 63 def { formData: JSON.parse(form_data), metadata: } end |
#expires_after ⇒ ActiveSupport::Duration
Determines an expiration duration based on the UI form_id. If the in_progress_form_custom_expiration feature is enabled, the method can additionally return custom expiration durations whose values are passed in as Strings from the UI.
89 90 91 92 93 94 95 96 |
# File 'app/models/in_progress_form.rb', line 89 def expires_after @expires_after ||= if Flipper.enabled?(:in_progress_form_custom_expiration) custom_expires_after else default_expires_after end end |
#metadata ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/in_progress_form.rb', line 70 def data = super || {} last_accessed = updated_at || Time.current data.merge( 'createdAt' => created_at&.to_time.to_i, 'expiresAt' => expires_at.to_i || (last_accessed + expires_after).to_i, 'lastUpdated' => updated_at.to_i, 'inProgressFormId' => id ) end |