metaprogramming

Declarative macros (macro_rules!) for code generation

Declarative macros (macro_rules!) let you write code that writes code, reducing boilerplate. They pattern-match on token trees and expand at compile time. I use them for repetitive patterns like implementing traits for multiple types or generating tes

Ruby refinements for scoped monkey patching

Refinements provide scoped modifications to existing classes without global monkey patching. I use refinements to add methods to core classes safely. Refinements activate with using statement—scope-limited to file or module. Unlike monkey patches, ref

Metaprogramming with method_missing and define_method

Ruby's metaprogramming enables dynamic method definition and interception. method_missing catches undefined method calls, allowing DSL creation and proxy patterns. I implement it carefully with respond_to_missing? for proper introspection. define_meth

Procedural macros for custom derives and attributes

Procedural macros operate on Rust syntax trees, enabling custom #[derive(...)], attribute macros, or function-like macros. I write proc macros for boilerplate reduction: auto-generating builders, serialization, or validation. They're more powerful tha