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
- ASSETS_MODES =
%i[auto importmap jsbundling sprockets].freeze
- PRECOMPILE_STRATEGIES =
%i[all minimal].freeze
Instance Attribute Summary collapse
-
#assets_mode ⇒ Object
Returns the value of attribute assets_mode.
-
#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.
-
#initializer_version ⇒ Object
Returns the value of attribute initializer_version.
-
#precompile_strategy ⇒ Object
Returns the value of attribute precompile_strategy.
-
#respect_reduced_motion ⇒ Object
Returns the value of attribute respect_reduced_motion.
-
#silence_initializer_warning ⇒ Object
Returns the value of attribute silence_initializer_warning.
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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/swal_rails/configuration.rb', line 28 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" # `initializer_version` left nil — apps that haven't regenerated # their initializer since `SwalRails::INITIALIZER_VERSION` was # introduced (0.3.3) get a one-line warning at boot. Setting it # explicitly in the initializer template silences it. @initializer_version = nil @silence_initializer_warning = false # `:auto` lets the engine sniff (importmap.rb, package.json) at boot. # Override in your initializer to lock the choice and skip the sniff. @assets_mode = :auto # `:all` keeps every sweetalert2 variant in the host's precompile # list (legacy behaviour, ~970 KB on disk). `:minimal` precompiles # only the variant the host's assets_mode actually uses, shaving # ~700 KB. Default stays `:all` for backwards compatibility — flip # to `:minimal` once you've confirmed your host doesn't reference # extra variants directly. @precompile_strategy = :all # `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
#assets_mode ⇒ Object
Returns the value of attribute assets_mode.
25 26 27 |
# File 'lib/swal_rails/configuration.rb', line 25 def assets_mode @assets_mode end |
#confirm_mode ⇒ Object
Returns the value of attribute confirm_mode.
25 26 27 |
# File 'lib/swal_rails/configuration.rb', line 25 def confirm_mode @confirm_mode end |
#default_options ⇒ Object
Returns the value of attribute default_options.
18 19 20 |
# File 'lib/swal_rails/configuration.rb', line 18 def @default_options end |
#expose_window_swal ⇒ Object
Returns the value of attribute expose_window_swal.
18 19 20 |
# File 'lib/swal_rails/configuration.rb', line 18 def expose_window_swal @expose_window_swal end |
#flash_array_mode ⇒ Object
Returns the value of attribute flash_array_mode.
25 26 27 |
# File 'lib/swal_rails/configuration.rb', line 25 def flash_array_mode @flash_array_mode end |
#flash_keys_as_meta ⇒ Object
Returns the value of attribute flash_keys_as_meta.
18 19 20 |
# File 'lib/swal_rails/configuration.rb', line 18 def @flash_keys_as_meta end |
#flash_map ⇒ Object
Returns the value of attribute flash_map.
25 26 27 |
# File 'lib/swal_rails/configuration.rb', line 25 def flash_map @flash_map end |
#flash_stack_delay ⇒ Object
Returns the value of attribute flash_stack_delay.
18 19 20 |
# File 'lib/swal_rails/configuration.rb', line 18 def flash_stack_delay @flash_stack_delay end |
#i18n_scope ⇒ Object
Returns the value of attribute i18n_scope.
25 26 27 |
# File 'lib/swal_rails/configuration.rb', line 25 def i18n_scope @i18n_scope end |
#initializer_version ⇒ Object
Returns the value of attribute initializer_version.
18 19 20 |
# File 'lib/swal_rails/configuration.rb', line 18 def initializer_version @initializer_version end |
#precompile_strategy ⇒ Object
Returns the value of attribute precompile_strategy.
25 26 27 |
# File 'lib/swal_rails/configuration.rb', line 25 def precompile_strategy @precompile_strategy end |
#respect_reduced_motion ⇒ Object
Returns the value of attribute respect_reduced_motion.
18 19 20 |
# File 'lib/swal_rails/configuration.rb', line 18 def respect_reduced_motion @respect_reduced_motion end |
#silence_initializer_warning ⇒ Object
Returns the value of attribute silence_initializer_warning.
18 19 20 |
# File 'lib/swal_rails/configuration.rb', line 18 def silence_initializer_warning @silence_initializer_warning end |
Instance Method Details
#to_client_payload ⇒ Object
Snapshot safe for serialization into a meta tag / JSON.
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/swal_rails/configuration.rb', line 107 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 |