module RailsSweetAlert2Confirm::ViewHelpers
Public Instance Methods
link_to(*args, &block)
click to toggle source
Calls superclass method
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 5 def link_to(*args, &block) options = args[block_given? ? 1 : 2] || {} options = merge_options_into_swal(options) super(*args, &block) end
submit_tag(value = 'Save changes', options = {})
click to toggle source
Calls superclass method
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 11 def submit_tag(value = 'Save changes', options = {}) options = merge_options_into_swal(options) super value, options end
Private Instance Methods
configure_swal_options(options)
click to toggle source
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 29 def configure_swal_options(options) options[:data] ||= {} options[:data][:swal] ||= {} end
fetch_option(option, options)
click to toggle source
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 44 def fetch_option(option, options) options.delete(option) || options[:data].delete(option) end
merge_options_into_swal(options)
click to toggle source
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 22 def merge_options_into_swal(options) return options unless options_have_confirm?(options) options = configure_swal_options(options) options = merge_swal_remote_options(options) options = merge_swal_confirm_options(options) end
merge_swal_confirm_options(options)
click to toggle source
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 39 def merge_swal_confirm_options(options) return options unless options_have_confirm?(options) options[:data][:swal][:title] = fetch_option(:confirm, options) end
merge_swal_remote_options(options)
click to toggle source
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 34 def merge_swal_remote_options(options) return options unless options_have_remote?(options) options[:data][:swal][:remote] = fetch_option(:remote, options) end
options_have_confirm?(options)
click to toggle source
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 48 def options_have_confirm?(options) (options[:confirm] || options.dig(:data, :confirm)).present? end
options_have_remote?(options)
click to toggle source
# File lib/rails_sweetalert2_confirm/view_helpers.rb, line 52 def options_have_remote?(options) (options[:remote] || options.dig(:data, :remote)).present? end