Class: Vident2::Internals::TargetBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vident2/internals/target_builder.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.

Fluent chain returned by ‘target(…)` inside a `stimulus do` block. The only current chain method is `.when` (conditional inclusion); the target itself has no other DSL-facing knobs.

target(:row).when { @rows.any? }

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ TargetBuilder

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.

Returns a new instance of TargetBuilder.



14
15
16
17
# File 'lib/vident2/internals/target_builder.rb', line 14

def initialize(*args)
  @args = args
  @when_proc = nil
end

Instance Method Details

#to_declarationObject

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.



24
25
26
# File 'lib/vident2/internals/target_builder.rb', line 24

def to_declaration
  Declaration.new(args: @args.freeze, when_proc: @when_proc, meta: {}.freeze)
end

#when(callable = nil, &block) ⇒ 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.



19
20
21
22
# File 'lib/vident2/internals/target_builder.rb', line 19

def when(callable = nil, &block)
  @when_proc = block || callable
  self
end