Module: Mycroseconds::Getting
- Defined in:
- lib/mycroseconds/getting.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 |
# File 'lib/mycroseconds/getting.rb', line 3 def self.included(base) base.class_eval do alias_method_chain :read_attribute, :precision end end |
Instance Method Details
#read_attribute_with_precision(attr_name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mycroseconds/getting.rb', line 9 def read_attribute_with_precision(attr_name) value = read_attribute_without_precision(attr_name) if (attr_name.to_s == 'updated_at') && precise_updated_at? && value.acts_like?(:time) precision = read_attribute_without_precision(:updated_at_precision) value += ((precision - value.usec).to_f / 1_000_000) end value end |