Class: Yes::Core::CommandHandling::PayloadProxy
- Inherits:
-
Object
- Object
- Yes::Core::CommandHandling::PayloadProxy
- Defined in:
- lib/yes/core/command_handling/payload_proxy.rb
Overview
Provides proxy access to command payload with dynamic aggregate resolution
Instance Method Summary collapse
-
#initialize(raw_payload:, context:, parent_aggregates:, raw_metadata: nil, aggregate_tracker: nil) ⇒ PayloadProxy
constructor
A new instance of PayloadProxy.
-
#metadata ⇒ MetadataProxy
Access metadata through a proxy object.
Constructor Details
#initialize(raw_payload:, context:, parent_aggregates:, raw_metadata: nil, aggregate_tracker: nil) ⇒ PayloadProxy
Returns a new instance of PayloadProxy.
12 13 14 15 16 17 18 |
# File 'lib/yes/core/command_handling/payload_proxy.rb', line 12 def initialize(raw_payload:, context:, parent_aggregates:, raw_metadata: nil, aggregate_tracker: nil) @raw_payload = raw_payload @raw_metadata = @context = context @parent_aggregates = parent_aggregates @aggregate_tracker = aggregate_tracker end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) { ... } ⇒ Object (private)
Handles dynamic method calls to access payload values or resolve aggregates
44 45 46 47 48 49 50 51 52 |
# File 'lib/yes/core/command_handling/payload_proxy.rb', line 44 def method_missing(method_name, *args, &) if raw_payload.key?(method_name) raw_payload[method_name] elsif raw_payload.key?(:"#{method_name}_id") resolve_aggregate(method_name) else super end end |
Instance Method Details
#metadata ⇒ MetadataProxy
Access metadata through a proxy object
29 30 31 |
# File 'lib/yes/core/command_handling/payload_proxy.rb', line 29 def @metadata ||= MetadataProxy.new(@raw_metadata) end |