Class: Yes::Core::CommandHandling::MetadataProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/yes/core/command_handling/payload_proxy.rb

Overview

Provides proxy access to command metadata

Instance Method Summary collapse

Constructor Details

#initialize(raw_metadata) ⇒ MetadataProxy

Returns a new instance of MetadataProxy.

Parameters:

  • raw_metadata (Hash)

    The raw command metadata



93
94
95
# File 'lib/yes/core/command_handling/payload_proxy.rb', line 93

def initialize()
  @raw_metadata =  || {}
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 or set metadata values

Parameters:

  • method_name (Symbol)

    The method being called

  • args (Array)

    Method arguments

Yields:

  • Optional block passed to the method (unused)

Yield Returns:

  • (void)

Returns:

  • (Object)

    The metadata value or the value being set



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/yes/core/command_handling/payload_proxy.rb', line 121

def method_missing(method_name, *args, &)
  method_str = method_name.to_s

  # Handle setter methods (e.g., xyz=)
  if method_str.end_with?('=')
    key = method_str.chomp('=').to_sym
    [key] = args.first
  # Handle getter methods
  elsif args.empty?
    if .key?(method_name)
      [method_name]
    elsif .key?(method_str)
      [method_str]
    end
  else
    super
  end
end