Class: AreWeThereYet::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/are_we_there_yet/metric.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Metric

Returns a new instance of Metric.



4
5
6
7
8
9
10
# 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

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/are_we_there_yet/metric.rb', line 3

def description
  @description
end

#execution_timeObject (readonly)

Returns the value of attribute execution_time.



3
4
5
# File 'lib/are_we_there_yet/metric.rb', line 3

def execution_time
  @execution_time
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/are_we_there_yet/metric.rb', line 3

def id
  @id
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/are_we_there_yet/metric.rb', line 3

def path
  @path
end

#run_idObject (readonly)

Returns the value of attribute run_id.



3
4
5
# File 'lib/are_we_there_yet/metric.rb', line 3

def run_id
  @run_id
end

Class Method Details

.all(datastore) ⇒ Object



17
18
19
# File 'lib/are_we_there_yet/metric.rb', line 17

def self.all(datastore)
  datastore[:metrics].all.map { |record| new record }
end

Instance Method Details

#save(datastore) ⇒ Object

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



13
14
15
# 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