Class: Synthra::Behaviors::Registry::BlockBehaviorInstance Private
- Defined in:
- lib/synthra/behaviors/registry.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance of a block-based behavior
Wraps a block in a Base-compatible interface.
Instance Method Summary collapse
-
#apply(result, context = nil) ⇒ Object
private
Apply the block behavior.
-
#initialize(value, rng, block) ⇒ BlockBehaviorInstance
constructor
private
Create a new block behavior instance.
Constructor Details
#initialize(value, rng, block) ⇒ BlockBehaviorInstance
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new block behavior instance
217 218 219 220 |
# File 'lib/synthra/behaviors/registry.rb', line 217 def initialize(value, rng, block) super(value, rng) @block = block end |
Instance Method Details
#apply(result, context = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Apply the block behavior
230 231 232 233 234 |
# File 'lib/synthra/behaviors/registry.rb', line 230 def apply(result, context = nil) return result unless should_apply? @block.call(context, result, value) end |