Module: Sevgi::Graphics::Module
- Defined in:
- lib/sevgi/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 when it has 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 may 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 in the current element context and does not receive the invocation arguments.
82 83 84 85 86 87 88 89 90 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 82 def base(&block) raise ::FrozenError, "can't modify frozen callable module" if frozen? ArgumentError.("Block required") unless block own_configuration @sevgi_bases << block nil end |