class Retl::PathBuilder
Public Class Methods
new(path, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 12 def initialize(path, &block) @path = path @next_descripion = NextDescription.new instance_eval(&block) end
Public Instance Methods
calculate(key, action=nil, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 53 def calculate(key, action=nil, &block) action ||= block transform { |data, context| data[key] = context.execute_step(action, data) } end
Also aliased as: calc
depends_on(name, source=nil, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 59 def depends_on(name, source=nil, &block) source ||= block @path.add_dependency(name, source) end
desc(step_description)
click to toggle source
# File lib/retl/path_builder.rb, line 73 def desc(step_description) @next_descripion.describe_next(step_description) end
explode(action=nil, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 64 def explode(action=nil, &block) action ||= block step(action, handler: ExplodeHandler) end
filter(predicate=nil, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 33 def filter(predicate=nil, &block) predicate ||= block step(predicate, handler: FilterHandler) end
Also aliased as: select
fork(name, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 39 def fork(name, &block) @path.add_fork_builder(name, &block) end
inspect(action=nil, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 43 def inspect(action=nil, &block) action ||= block step(action, handler: InspectHandler) end
path(path, dependencies={}, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 69 def path(path, dependencies={}, &block) @path.add_handler PathHandler.new(path, dependencies, &block) end
reject(predicate=nil, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 48 def reject(predicate=nil, &block) predicate ||= block filter { |data, context| !context.execute_step(predicate, data) } end
step(step=nil, handler: StepHandler, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 18 def step(step=nil, handler: StepHandler, &block) step ||= block handler = handler.new(step) handler.description = @next_descripion.take @path.add_handler handler end
Also aliased as: replace
transform(action=nil, &block)
click to toggle source
# File lib/retl/path_builder.rb, line 28 def transform(action=nil, &block) action ||= block step(action, handler: TransformHandler) end