Class: EntityCache::Record
- Inherits:
-
Struct
- Object
- Struct
- EntityCache::Record
- Defined in:
- lib/entity_cache/record.rb,
lib/entity_cache/record.rb,
lib/entity_cache/record/log_text.rb,
lib/entity_cache/record/destructure.rb,
lib/entity_cache/record/transformer.rb
Defined Under Namespace
Modules: Destructure, LogText, Transformer
Instance Attribute Summary collapse
-
#entity ⇒ Object
Returns the value of attribute entity.
-
#id ⇒ Object
Returns the value of attribute id.
-
#persisted_time ⇒ Object
Returns the value of attribute persisted_time.
-
#persisted_version ⇒ Object
Returns the value of attribute persisted_version.
-
#time ⇒ Object
Returns the value of attribute time.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .build(id, entity, version, time, persisted_version: nil, persisted_time: nil) ⇒ Object
- .destructure(instance, includes = nil) ⇒ Object
Instance Method Summary collapse
- #age_milliseconds ⇒ Object
- #configure ⇒ Object
- #persisted_age_milliseconds ⇒ Object
- #persisted_age_versions ⇒ Object
Instance Attribute Details
#entity ⇒ Object
Returns the value of attribute entity
2 3 4 |
# File 'lib/entity_cache/record.rb', line 2 def entity @entity end |
#id ⇒ Object
Returns the value of attribute id
2 3 4 |
# File 'lib/entity_cache/record.rb', line 2 def id @id end |
#persisted_time ⇒ Object
Returns the value of attribute persisted_time
2 3 4 |
# File 'lib/entity_cache/record.rb', line 2 def persisted_time @persisted_time end |
#persisted_version ⇒ Object
Returns the value of attribute persisted_version
2 3 4 |
# File 'lib/entity_cache/record.rb', line 2 def persisted_version @persisted_version end |
#time ⇒ Object
Returns the value of attribute time
2 3 4 |
# File 'lib/entity_cache/record.rb', line 2 def time @time end |
#version ⇒ Object
Returns the value of attribute version
2 3 4 |
# File 'lib/entity_cache/record.rb', line 2 def version @version end |
Class Method Details
.build(id, entity, version, time, persisted_version: nil, persisted_time: nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/entity_cache/record.rb', line 18 def self.build(id, entity, version, time, persisted_version: nil, persisted_time: nil) instance = new(id, entity, version, time, persisted_version, persisted_time) instance.configure instance end |
.destructure(instance, includes = nil) ⇒ Object
24 25 26 |
# File 'lib/entity_cache/record.rb', line 24 def self.destructure(instance, includes=nil) Destructure.(instance, includes) end |
Instance Method Details
#age_milliseconds ⇒ Object
28 29 30 |
# File 'lib/entity_cache/record.rb', line 28 def age_milliseconds Clock::UTC.elapsed_milliseconds(time, clock.now) end |
#configure ⇒ Object
14 15 16 |
# File 'lib/entity_cache/record.rb', line 14 def configure Clock::UTC.configure(self) end |
#persisted_age_milliseconds ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/entity_cache/record.rb', line 32 def persisted_age_milliseconds if persisted_time.nil? nil else Clock::UTC.elapsed_milliseconds( persisted_time, time ) end end |
#persisted_age_versions ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/entity_cache/record.rb', line 43 def persisted_age_versions if persisted_version.nil? nil else version - persisted_version end end |