Module: MultiModelWizard::Wizard

Extended by:
ActiveSupport::Concern
Includes:
CookieStore, RedisCookieStore
Defined in:
lib/multi_model_wizard/wizard.rb

Constant Summary

Constants included from CookieStore

CookieStore::EXPIRATION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RedisCookieStore

#clear_redis_cache, #fetch_redis_cache, #set_redis_cache

Methods included from CookieStore

#delete_cookie, #get_signed_cookie, #set_signed_cookie

Instance Attribute Details

#form_idObject (readonly)

Returns the value of attribute form_id.



24
25
26
# File 'lib/multi_model_wizard/wizard.rb', line 24

def form_id
  @form_id
end

Instance Method Details

#clear_session_paramsObject

This clears the form data from the session cookie or redis depending on whats configured



32
33
34
# File 'lib/multi_model_wizard/wizard.rb', line 32

def clear_session_params
  store_in_redis? ? clear_redis_session_params : clear_cookie_session_params
end

#multi_model_wizard_form_keyObject

Reference the form key that was passed in from the initializer



52
53
54
# File 'lib/multi_model_wizard/wizard.rb', line 52

def multi_model_wizard_form_key
  ::MultiModelWizard.configuration.form_key
end

#session_paramsObject

This gets the form data from the session cookie or redis depending on whats configured



27
28
29
# File 'lib/multi_model_wizard/wizard.rb', line 27

def session_params
  store_in_redis? ? redis_session_params : cookie_session_params
end

#set_session_params(value) ⇒ Object

This sets the form data in the session cookie or redis depending on whats configured



37
38
39
# File 'lib/multi_model_wizard/wizard.rb', line 37

def set_session_params(value)
  store_in_redis? ? set_redis_session_params(value) : set_cookie_session_params(value)
end

#wizard_form_uuidObject

Wizard form uuid will attempt to get the uuid from the browser session cookie If one is not there it will set a new session cookie with the uuid as teh value



43
44
45
46
47
48
49
# File 'lib/multi_model_wizard/wizard.rb', line 43

def wizard_form_uuid
  return get_signed_cookie(wizard_form_key) if get_signed_cookie(wizard_form_key).present?

  @uuid ||= SecureRandom.uuid
  set_signed_cookie(key: wizard_form_key, value: @uuid)
  @uuid
end