Sha256: 2324aa2da837b2ff08f8af23229e9ebaddc2ba0280d89639ff0b4bbeba2cd2da
Contents?: true
Size: 896 Bytes
Versions: 8
Compression:
Stored size: 896 Bytes
Contents
module AutoError class AppErrorDecorator < Draper::Decorator def as_json( context ) r = source.attributes (r['data']||{}).entries.each do |k, v| next if v.nil? k = k.to_sym if k != :params || AutoError::Config.data_handlers.has_key?(k) handler = AutoError::Config.data_handlers[k].bind(context) processed = handler.(v) elsif k == :params processed = handle_params(v) end r['data'][k.to_s] = processed.html_safe end r end private def handle_params( h ) %{ <a href='javascript:void(0);' onclick='$(this).siblings(".params").reveal();'>show params...</a> <div class='params reveal-modal'> <a class="close-reveal-modal">×</a> <h4>Params</h4> <pre>#{JSON.pretty_generate(h)}</pre> </div> } end end end
Version data entries
8 entries across 8 versions & 1 rubygems