Class: Vanity::Adapters::ActiveRecordAdapter::VanityMetric

Inherits:
VanityRecord
  • Object
show all
Defined in:
lib/vanity/adapters/active_record_adapter.rb

Overview

Metric model

Constant Summary collapse

UPDATED_AT_GRACE_PERIOD =
1.minute

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from VanityRecord

needs_attr_accessible?, rails_agnostic_find_or_create_by

Class Method Details

.retrieve(metric) ⇒ Object


47
48
49
# File 'lib/vanity/adapters/active_record_adapter.rb', line 47

def self.retrieve(metric)
  rails_agnostic_find_or_create_by(:metric_id, metric.to_s)
end

Instance Method Details

#touch_with_grace_periodObject


51
52
53
54
# File 'lib/vanity/adapters/active_record_adapter.rb', line 51

def touch_with_grace_period
  now = Time.now
  self.updated_at = now if updated_before_grace_period?(now)
end