Class: Babl::Nodes::Switch
- Inherits:
-
Object
- Object
- Babl::Nodes::Switch
- Defined in:
- lib/babl/nodes/switch.rb
Instance Method Summary collapse
Instance Method Details
#dependencies ⇒ Object
9 10 11 12 |
# File 'lib/babl/nodes/switch.rb', line 9 def dependencies (nodes.values + nodes.keys).map(&:dependencies) .reduce({}) { |a, b| Babl::Utils::Hash.deep_merge(a, b) } end |
#pinned_dependencies ⇒ Object
14 15 16 17 |
# File 'lib/babl/nodes/switch.rb', line 14 def pinned_dependencies (nodes.values + nodes.keys).map(&:pinned_dependencies) .reduce({}) { |a, b| Babl::Utils::Hash.deep_merge(a, b) } end |
#render(ctx) ⇒ Object
23 24 25 26 |
# File 'lib/babl/nodes/switch.rb', line 23 def render(ctx) nodes.each { |cond, value| return value.render(ctx) if cond.render(ctx) } raise Errors::RenderingError, 'A least one switch() condition must be taken' end |
#schema ⇒ Object
19 20 21 |
# File 'lib/babl/nodes/switch.rb', line 19 def schema Schema::AnyOf.canonicalized(nodes.values.map(&:schema)) end |