Sha256: 56e45b84d4d2185c35231a9df41a0f3c4c0416a58189373b0d51860b46eb581d
Contents?: true
Size: 902 Bytes
Versions: 6
Compression:
Stored size: 902 Bytes
Contents
module Vega module Helper def vega_chart(chart, nonce: true) unless chart.is_a?(Vega::BaseChart) || chart.is_a?(Hash) raise TypeError, "expected Vega chart or spec" end if nonce == true # Secure Headers also defines content_security_policy_nonce but it takes an argument # Rails 5.2 overrides this method, but earlier versions do not if respond_to?(:content_security_policy_nonce) && (content_security_policy_nonce rescue nil) # Rails 5.2 nonce = content_security_policy_nonce elsif respond_to?(:content_security_policy_script_nonce) # Secure Headers nonce = content_security_policy_script_nonce else nonce = nil end end if chart.is_a?(Hash) Vega.render(chart, nonce: nonce) else chart.to_html(nonce: nonce) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
vega-0.4.0 | lib/vega/helper.rb |
vega-0.3.2 | lib/vega/helper.rb |
vega-0.3.1 | lib/vega/helper.rb |
vega-0.3.0 | lib/vega/helper.rb |
vega-0.2.7 | lib/vega/helper.rb |
vega-0.2.6 | lib/vega/helper.rb |