class TimeStreamer::App

Public Instance Methods

adapter() click to toggle source
# File lib/time_streamer/app.rb, line 55
def adapter
  TimeStreamer.configuration.adapter
end
associations_for(parent) click to toggle source
# File lib/time_streamer/app.rb, line 32
def associations_for(parent)
  return if parent.nil?

  associations = load_associations parent
  associations.transform_values! do |value|
    Array(value).map { |record| adapter.identifier_for(record) }
  end
  associations.reject { |_, value| value.empty? }
end
format_time(time) click to toggle source
# File lib/time_streamer/app.rb, line 47
def format_time(time)
  time.strftime '%Y-%m-%d %H:%M:%S'
end
ignored_associations(model_class) click to toggle source
# File lib/time_streamer/app.rb, line 59
def ignored_associations(model_class)
  global = TimeStreamer.configuration.global_ignored_associations
  specific = TimeStreamer.configuration.ignored_associations.fetch(model_class.to_s) { [] }
  global | specific
end
load_associations(record) click to toggle source
# File lib/time_streamer/app.rb, line 42
def load_associations(record)
  associations = record.class.reflections.keys - ignored_associations(record.class)
  associations.map { |key| [key, record.send(key)] }.to_h
end
mount_path() click to toggle source
# File lib/time_streamer/app.rb, line 65
def mount_path
  TimeStreamer.configuration.mount_path
end
versions_to_view_models(versions) click to toggle source
# File lib/time_streamer/app.rb, line 51
def versions_to_view_models(versions)
  versions.map { |version| VersionViewModel.new adapter.version_data(version) }
end