Class: SwalRails::Configuration
- Inherits:
-
Object
- Object
- SwalRails::Configuration
- Defined in:
- lib/swal_rails/configuration.rb
Overview
Constant Summary collapse
- CONFIRM_MODES =
%i[off data_attribute turbo_override both].freeze
- FLASH_ARRAY_MODES =
%i[sequential stacked].freeze
Instance Attribute Summary collapse
-
#confirm_mode ⇒ Object
Returns the value of attribute confirm_mode.
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#expose_window_swal ⇒ Object
Returns the value of attribute expose_window_swal.
-
#flash_array_mode ⇒ Object
Returns the value of attribute flash_array_mode.
-
#flash_keys_as_meta ⇒ Object
Returns the value of attribute flash_keys_as_meta.
-
#flash_map ⇒ Object
Returns the value of attribute flash_map.
-
#flash_stack_delay ⇒ Object
Returns the value of attribute flash_stack_delay.
-
#i18n_scope ⇒ Object
Returns the value of attribute i18n_scope.
-
#respect_reduced_motion ⇒ Object
Returns the value of attribute respect_reduced_motion.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#to_client_payload ⇒ Object
Snapshot safe for serialization into a meta tag / JSON.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/swal_rails/configuration.rb', line 23 def initialize @confirm_mode = :data_attribute @flash_keys_as_meta = true @respect_reduced_motion = true @expose_window_swal = true @flash_array_mode = :sequential @flash_stack_delay = 500 @i18n_scope = "swal_rails" # `focusConfirm` / `returnFocus` are intentionally omitted: SA2 already # defaults both to `true` internally, and passing them explicitly makes # SA2 warn on every toast ("incompatible with toasts"). Listing them # here would be a no-op behaviorally and a noise generator. @default_options = { buttonsStyling: true, reverseButtons: false } @flash_map = default_flash_map end |
Instance Attribute Details
#confirm_mode ⇒ Object
Returns the value of attribute confirm_mode.
21 22 23 |
# File 'lib/swal_rails/configuration.rb', line 21 def confirm_mode @confirm_mode end |
#default_options ⇒ Object
Returns the value of attribute default_options.
16 17 18 |
# File 'lib/swal_rails/configuration.rb', line 16 def @default_options end |
#expose_window_swal ⇒ Object
Returns the value of attribute expose_window_swal.
16 17 18 |
# File 'lib/swal_rails/configuration.rb', line 16 def expose_window_swal @expose_window_swal end |
#flash_array_mode ⇒ Object
Returns the value of attribute flash_array_mode.
21 22 23 |
# File 'lib/swal_rails/configuration.rb', line 21 def flash_array_mode @flash_array_mode end |
#flash_keys_as_meta ⇒ Object
Returns the value of attribute flash_keys_as_meta.
16 17 18 |
# File 'lib/swal_rails/configuration.rb', line 16 def @flash_keys_as_meta end |
#flash_map ⇒ Object
Returns the value of attribute flash_map.
21 22 23 |
# File 'lib/swal_rails/configuration.rb', line 21 def flash_map @flash_map end |
#flash_stack_delay ⇒ Object
Returns the value of attribute flash_stack_delay.
16 17 18 |
# File 'lib/swal_rails/configuration.rb', line 16 def flash_stack_delay @flash_stack_delay end |
#i18n_scope ⇒ Object
Returns the value of attribute i18n_scope.
21 22 23 |
# File 'lib/swal_rails/configuration.rb', line 21 def i18n_scope @i18n_scope end |
#respect_reduced_motion ⇒ Object
Returns the value of attribute respect_reduced_motion.
16 17 18 |
# File 'lib/swal_rails/configuration.rb', line 16 def respect_reduced_motion @respect_reduced_motion end |
Instance Method Details
#to_client_payload ⇒ Object
Snapshot safe for serialization into a meta tag / JSON.
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/swal_rails/configuration.rb', line 70 def to_client_payload { confirmMode: confirm_mode, respectReducedMotion: respect_reduced_motion, exposeWindowSwal: expose_window_swal, defaultOptions: , flashMap: flash_map, flashArrayMode: flash_array_mode, flashStackDelay: flash_stack_delay, i18n: i18n_payload } end |