Disclaimer: I've not used Dashing (although it looks quite interesting).
From the docs:
…
send_event('karma', { current: rand(1000) })
…This job will run every minute, and will send a random number to ALL widgets that have data-id set to 'karma'.
You send data using the following method:
send_event(widget_id, json_formatted_data)
So for your collection, you need an array of hashes, each hash has the keys label
and value
(as instance method calls on an object in coffeescript are (in Ruby speak) really just accessors on a hash).
Once you have that collection, transform it into JSON, and stick it in an object with the accessor items
, e.g.
require 'json'
items = [{label: "l1", value: "v1"},{label: "l2", value: "v2"},{label: "l3", value: "v3"}]
json_formatted_items = items.to_json
# => "[{\"label\":\"l1\",\"value\":\"v1\"},{\"label\":\"l2\",\"value\":\"v2\"},{\"label\":\"l3\",\"value\":\"v3\"}]"
SCHEDULER.every '1m', :first_in => 0 do |job|
send_event('widget_id', {items: json_formatted_items })
end
I don't know if that will work, but that's what I think will work. Hope it helps.