Challenge 3: A Minimal OpenStruct — Solution class DynamicRecord def initialize(attributes) @attributes = attributes end def method_missing(method_name, *args) if @attributes.key?(method_name) @attributes[method_name] else super end end def respond_to_missing?(method_name, include_private = false) @attributes.key?(method_name) || super end end record = DynamicRecord.new(name: "Philip", role: "Student") puts record.name puts record.role puts record.respond_to?(:name) puts record.respond_to?(:nonexistent_field) =begin Output: Philip Student true false Notes: - method_missing checks whether the called method's name matches a key in @attributes; if so, it returns that value instead of raising NoMethodError. Calling super in the else branch preserves normal Ruby behavior for any genuinely unhandled method name. - respond_to_missing? mirrors the exact same check, which is why record.respond_to?(:name) correctly returns true even though name was never defined with def anywhere in the class. - record.respond_to?(:nonexistent_field) correctly returns false, proving respond_to_missing? and method_missing agree with each other — the chapter's warning about skipping respond_to_missing? would show up here as a mismatch between what respond_to? reports and what actually happens when the method is called. =end