Module: Trailblazer::Endpoint::Options::DSL

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

Defined Under Namespace

Modules: Inherit

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(extended) ⇒ Object

Called in Controller.



18
19
20
# File 'lib/trailblazer/endpoint/options.rb', line 18

def self.extended(extended) # TODO: let's hope this is only called once per hierachy :)
  extended.instance_variable_set(:@normalizers, {})
end

Instance Method Details

#directive(directive_name, *callables, inherit: superclass) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/trailblazer/endpoint/options.rb', line 7

def directive(directive_name, *callables, inherit: superclass)
  options = {}

  if inherit
    options[:base_class] = instance_variable_get(:@normalizers)[directive_name] || Trailblazer::Activity::Path # FIXME
  end

  @normalizers[directive_name] = Trailblazer::Endpoint::Normalizer.Options(directive_name, *callables, **options) # DISCUSS: allow multiple calls?
end