Class: SolidObjects::StateSnapshot
- Inherits:
-
Object
- Object
- SolidObjects::StateSnapshot
- Defined in:
- lib/solid_objects/state_snapshot.rb,
sig/generated/lib/solid_objects/state_snapshot.rbs
Instance Attribute Summary collapse
-
#actor_class ⇒ Object
readonly
Returns the value of attribute actor_class.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #attribute?(name) ⇒ Boolean
-
#initialize(reference) ⇒ StateSnapshot
constructor
A new instance of StateSnapshot.
- #method_missing(name, *arguments, **keywords) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
- #to_h ⇒ Hash[String, untyped]
Constructor Details
#initialize(reference) ⇒ StateSnapshot
Returns a new instance of StateSnapshot.
9 10 11 12 13 |
# File 'lib/solid_objects/state_snapshot.rb', line 9 def initialize(reference) actor_snapshot = ActorSnapshot.new(reference) @actor_class = actor_snapshot.actor_class @data = Serialization.readonly_copy(actor_snapshot.actor.state.to_h) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arguments, **keywords) ⇒ Object
21 22 23 24 25 |
# File 'lib/solid_objects/state_snapshot.rb', line 21 def method_missing(name, *arguments, **keywords) return data.fetch(name.to_s) if arguments.empty? && keywords.empty? && attribute?(name) super end |
Instance Attribute Details
#actor_class ⇒ Object (readonly)
Returns the value of attribute actor_class.
34 35 36 |
# File 'lib/solid_objects/state_snapshot.rb', line 34 def actor_class @actor_class end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
34 35 36 |
# File 'lib/solid_objects/state_snapshot.rb', line 34 def data @data end |
Instance Method Details
#attribute?(name) ⇒ Boolean
37 38 39 |
# File 'lib/solid_objects/state_snapshot.rb', line 37 def attribute?(name) actor_class.definition.state_definition.to_h.key?(name.to_sym) end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
28 29 30 |
# File 'lib/solid_objects/state_snapshot.rb', line 28 def respond_to_missing?(name, include_private = false) attribute?(name) || super end |
#to_h ⇒ Hash[String, untyped]
16 17 18 |
# File 'lib/solid_objects/state_snapshot.rb', line 16 def to_h data end |