Module: Trailblazer::Endpoint::Options

Defined in:
lib/trailblazer/endpoint/options.rb

Defined Under Namespace

Modules: DSL

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.merge_with(merged, hash) ⇒ Object

Merge merged into hash, but only keys that exist in hash.



45
46
47
48
49
# File 'lib/trailblazer/endpoint/options.rb', line 45

def self.merge_with(merged, hash)
  keys = hash.keys
  merged = keys.collect { |key| merged.key?(key) ? [key, merged[key]] : nil }.compact.to_h
  hash.merge(merged)
end

Instance Method Details

#options_for(directive_name, runtime_options) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/trailblazer/endpoint/options.rb', line 31

def options_for(directive_name, runtime_options)
  normalizer = @normalizers.fetch(directive_name)

  ctx = Trailblazer::Context(runtime_options, {})

  # signal, (ctx, ) = Trailblazer::Developer.wtf?(normalizer, [ctx])
  signal, (ctx, ) = Trailblazer::Activity::TaskWrap.invoke(normalizer, [ctx])

  _, options = ctx.decompose
  options
end