module DashingContrib::History
Public Instance Methods
append_to(target_array=[], source_obj = {}, max_size=1000)
click to toggle source
# File lib/dashing-contrib/history.rb, line 35 def append_to(target_array=[], source_obj = {}, max_size=1000) target_array.shift while target_array.size >= max_size target_array << source_obj end
history()
click to toggle source
# File lib/dashing-contrib/history.rb, line 8 def history Sinatra::Application.settings.history end
history_file()
click to toggle source
# File lib/dashing-contrib/history.rb, line 12 def history_file Sinatra::Application.settings.history_file end
json_event(event_name, default = nil)
click to toggle source
# File lib/dashing-contrib/history.rb, line 29 def json_event(event_name, default = nil) MultiJson.load(raw_event(event_name), { symbolize_keys: true }) rescue default end
raw_event(event_name)
click to toggle source
# File lib/dashing-contrib/history.rb, line 22 def raw_event(event_name) return nil if history[event_name].nil? history[event_name].gsub(/^data:/, '') rescue nil end
save()
click to toggle source
# File lib/dashing-contrib/history.rb, line 16 def save File.open(history_file, 'w') do |f| f.puts history.to_yaml end end