class AreWeThereYet::Metric

Attributes

description[R]
execution_time[R]
id[R]
path[R]
run_id[R]

Public Class Methods

all(datastore) click to toggle source
# File lib/are_we_there_yet/metric.rb, line 17
def self.all(datastore)
  datastore[:metrics].all.map { |record| new record }
end
new(options={}) click to toggle source
# File lib/are_we_there_yet/metric.rb, line 4
def initialize(options={})
  @id = options[:id]
  @execution_time = options[:execution_time]
  @path = options[:path]
  @run_id = options[:run_id]
  @description = options[:description]
end

Public Instance Methods

save(datastore) click to toggle source

Only works for creates not for updates - will need to be cleverer if we ever need to provide for updates

# File lib/are_we_there_yet/metric.rb, line 13
def save(datastore)
  @id = datastore[:metrics].insert(to_h.merge(:created_at => Time.now.utc))
end

Private Instance Methods

to_h() click to toggle source
# File lib/are_we_there_yet/metric.rb, line 23
def to_h
  { :execution_time => execution_time, :path => path, :description => description, :run_id => run_id }
end