Class: SolidObjects::ActorSnapshot
- Inherits:
-
Object
- Object
- SolidObjects::ActorSnapshot
- Defined in:
- lib/solid_objects/actor_snapshot.rb,
sig/generated/lib/solid_objects/actor_snapshot.rbs
Instance Attribute Summary collapse
- #actor ⇒ Object readonly
- #actor_class ⇒ Object readonly
- #reference ⇒ Object readonly
Instance Method Summary collapse
- #build_actor ⇒ Actor
-
#initialize(reference) ⇒ ActorSnapshot
constructor
A new instance of ActorSnapshot.
- #observable_values ⇒ Hash[String, untyped]
Constructor Details
#initialize(reference) ⇒ ActorSnapshot
Returns a new instance of ActorSnapshot.
12 13 14 15 16 |
# File 'lib/solid_objects/actor_snapshot.rb', line 12 def initialize(reference) @reference = reference @actor_class = SolidObjects.registry.fetch(reference.actor_type) @actor = build_actor end |
Instance Attribute Details
#actor ⇒ Object (readonly)
9 10 11 |
# File 'lib/solid_objects/actor_snapshot.rb', line 9 def actor @actor end |
#actor_class ⇒ Object (readonly)
9 10 11 |
# File 'lib/solid_objects/actor_snapshot.rb', line 9 def actor_class @actor_class end |
#reference ⇒ Object (readonly)
9 10 11 |
# File 'lib/solid_objects/actor_snapshot.rb', line 9 def reference @reference end |
Instance Method Details
#build_actor ⇒ Actor
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/solid_objects/actor_snapshot.rb', line 26 def build_actor instance = Instance.find_by( actor_type: reference.actor_type, actor_id: reference.actor_id ) state_version = instance&.state_version || actor_class.state_version state_data = ApplicationWriteGuard.call( actor_type: reference.actor_type, actor_id: reference.actor_id, operation: "state_migration" ) do actor_class.definition.migrate_state( state_version, instance&.state || {} ) end actor_class.new( actor_id: reference.actor_id, state: State.new(actor_class.definition.state_definition, state_data) ) end |
#observable_values ⇒ Hash[String, untyped]
19 20 21 |
# File 'lib/solid_objects/actor_snapshot.rb', line 19 def observable_values actor.observable_values end |