module Trailblazer::Endpoint::Normalizer
Public Class Methods
CallDirective(callable, option_name)
click to toggle source
# File lib/trailblazer/endpoint/options.rb, line 78 def self.CallDirective(callable, option_name) ->((ctx, flow_options), *) { config = callable.(ctx, **ctx) # e.g. ApplicationController.options_for_endpoint # ctx[option_name] = ctx[option_name].merge(config) config.each do |k, v| ctx[k] = v end return Trailblazer::Activity::Right, [ctx, flow_options] } end
DefaultToEmptyHash(config_name)
click to toggle source
# File lib/trailblazer/endpoint/options.rb, line 60 def self.DefaultToEmptyHash(config_name) -> (ctx, **) { ctx[config_name] ||= {} } end
Options(directive_name, *callables, base_class: Trailblazer::Activity::Path)
click to toggle source
# File lib/trailblazer/endpoint/options.rb, line 53 def self.Options(directive_name, *callables, base_class: Trailblazer::Activity::Path) normalizer = Class.new(base_class) do end Normalizer.add(normalizer, directive_name, callables) end
add(normalizer, directive_name, options)
click to toggle source
# File lib/trailblazer/endpoint/options.rb, line 70 def self.add(normalizer, directive_name, options) Class.new(normalizer) do options.collect do |callable| step task: Normalizer.CallDirective(callable, directive_name), id: "#{directive_name}=>#{callable}" end end end
add_normalizer!(target, normalizer, config)
click to toggle source
# File lib/trailblazer/endpoint/options.rb, line 64 def self.add_normalizer!(target, normalizer, config) normalizer = Normalizer.add(normalizer, target, config) # add configure steps for {subclass} to the _new_ normalizer. target.instance_variable_set(:@normalizer, normalizer) target.instance_variable_set(:@config, config) end