class RoughSwal::Renderer
Public Class Methods
call(*args)
click to toggle source
# File lib/rough_swal.rb, line 136 def call(*args) new(*args) end
new(session)
click to toggle source
# File lib/rough_swal.rb, line 142 def initialize(session) @session = session end
Public Instance Methods
code(params)
click to toggle source
# File lib/rough_swal.rb, line 154 def code(params) function = if (function = params.delete('function')).present? "," + function end "swal(#{params.to_json}#{function});" end
parse(params)
click to toggle source
# File lib/rough_swal.rb, line 163 def parse(params) params.map do |key, value| [key.to_s.camelize(:lower), value] end.to_h end
render()
click to toggle source
# File lib/rough_swal.rb, line 147 def render return ' ' if (params = @session.delete(:sweet_alert)).nil? tag(code(parse(params))).html_safe end
tag(js)
click to toggle source
# File lib/rough_swal.rb, line 170 def tag(js) "<script>#{js}</script>" end