Module: Sumi::Graphics::Module
- Defined in:
- graphics/lib/sumi/graphics/mixtures/call.rb
Overview
Callable drawing module support.
Extend a plain Ruby module with this API to make its public instance methods callable drawing steps. Name the
method call when the module has a single drawing step. Use descriptive method names for multiple steps.
Base blocks add argument-independent shared SVG content once per invocation before the public drawing methods.
Invocation does not change the configured module, so it can be frozen after its drawing steps are defined. A
duplicate or clone owns an independent configuration snapshot. Freezing a callable module prevents later base
registration while leaving invocation available.
Instance Method Summary collapse
-
#base { ... } ⇒ nil
Registers argument-independent shared drawing steps.
Instance Method Details
#base { ... } ⇒ nil
Registers argument-independent shared drawing steps. Every invocation runs inherited base blocks parent-first, then locally registered base blocks in registration order, before the module's public drawing methods. The block runs once on the callable receiver, which delegates drawing words to the current SVG element. It receives no invocation arguments. Callable methods receive those arguments and the caller's block unchanged.
83 84 85 86 87 88 89 90 91 |
# File 'graphics/lib/sumi/graphics/mixtures/call.rb', line 83 def base(&block) raise ::FrozenError, "can't modify frozen callable module" if frozen? ArgumentError.("Block required") unless block own_configuration @sumi_bases << block nil end |