Class: ExcADG::VStateData::Full
Overview
contains actual data
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#vertex ⇒ Object
readonly
Returns the value of attribute vertex.
Instance Method Summary collapse
-
#initialize(state:, data:, name:, vertex: nil) ⇒ Full
constructor
param state: Symbol, one of StateMachine.GRAPH.vertices param data: all data returned by a Vertice’s Payload param name: Symboli -c name of the associated Vertex param vertex: Vertex that produced the data.
-
#method_missing(method, *_args, &_block) ⇒ Object
auto-generated methods to check states easier; note: define_method causes these object to become un-shareable what breaks Broker’s messaging.
- #respond_to_missing?(method, *_args) ⇒ Boolean
-
#to_json(*args) ⇒ Object
method omits objects without a good known text representation.
-
#to_key ⇒ Object
converts full object to key to use in Hash.
- #to_s ⇒ Object
Methods inherited from Key
Constructor Details
#initialize(state:, data:, name:, vertex: nil) ⇒ Full
param state: Symbol, one of StateMachine.GRAPH.vertices param data: all data returned by a Vertice’s Payload param name: Symboli -c name of the associated Vertex param vertex: Vertex that produced the data
53 54 55 56 57 58 |
# File 'lib/excadg/vstate_data.rb', line 53 def initialize state:, data:, name:, vertex: nil # observation: Ractor.current returns Vertex object if invoked from a Vertex super(name:, vertex: vertex || Ractor.current) @state = state @data = data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args, &_block) ⇒ Object
auto-generated methods to check states easier; note: define_method causes these object to become un-shareable what breaks Broker’s messaging
81 82 83 84 85 |
# File 'lib/excadg/vstate_data.rb', line 81 def method_missing(method, *_args, &_block) raise NoMethodError unless respond_to_missing? method, _args @state.eql? method[...-1].to_sym end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
47 48 49 |
# File 'lib/excadg/vstate_data.rb', line 47 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
47 48 49 |
# File 'lib/excadg/vstate_data.rb', line 47 def name @name end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
47 48 49 |
# File 'lib/excadg/vstate_data.rb', line 47 def state @state end |
#vertex ⇒ Object (readonly)
Returns the value of attribute vertex.
47 48 49 |
# File 'lib/excadg/vstate_data.rb', line 47 def vertex @vertex end |
Instance Method Details
#respond_to_missing?(method, *_args) ⇒ Boolean
87 88 89 |
# File 'lib/excadg/vstate_data.rb', line 87 def respond_to_missing? method, *_args method.to_s.end_with?('?') && ExcADG::StateMachine::GRAPH.has_vertex?(method[...-1].to_sym) end |
#to_json(*args) ⇒ Object
method omits objects without a good known text representation
65 66 67 68 69 70 71 |
# File 'lib/excadg/vstate_data.rb', line 65 def to_json(*args) { name: @name, state: @state, data: @data }.to_json(*args) end |
#to_key ⇒ Object
converts full object to key to use in Hash
74 75 76 |
# File 'lib/excadg/vstate_data.rb', line 74 def to_key Key.new vertex: @vertex, name: @name end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/excadg/vstate_data.rb', line 60 def to_s "#{name || vertex} (#{state})" end |