Module: Trailblazer::Endpoint::Controller::DSL::Endpoint
- Defined in:
- lib/trailblazer/endpoint/controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build_endpoint(name, domain_activity: name, **options) ⇒ Object
-
#endpoint(name = nil, **options, &block) ⇒ Object
Builds and registers an endpoint in a controller class.
-
#generic_endpoint_config(**options) ⇒ Object
Configures generic :adapter, :protocol, etc.
Class Method Details
.extended(extended) ⇒ Object
91 92 93 |
# File 'lib/trailblazer/endpoint/controller.rb', line 91 def self.extended(extended) extended.directive(:endpoints, ->(*) { {} }) end |
Instance Method Details
#build_endpoint(name, domain_activity: name, **options) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/trailblazer/endpoint/controller.rb', line 115 def build_endpoint(name, domain_activity: name, **) = (:generic_options, {}).merge(domain_activity: domain_activity, **) # DISCUSS: why don't we add this as another directive option/step? endpoint = Trailblazer::Endpoint.build(**) directive :endpoints, ->(*) { {name.to_s => endpoint} } end |
#endpoint(name = nil, **options, &block) ⇒ Object
Builds and registers an endpoint in a controller class.
96 97 98 99 100 101 102 |
# File 'lib/trailblazer/endpoint/controller.rb', line 96 def endpoint(name=nil, **, &block) = .merge(protocol_block: block) if block_given? return generic_endpoint_config(**) if name.nil? build_endpoint(name, **) end |
#generic_endpoint_config(**options) ⇒ Object
Configures generic :adapter, :protocol, etc.
105 106 107 108 109 110 111 112 113 |
# File 'lib/trailblazer/endpoint/controller.rb', line 105 def generic_endpoint_config(**) self.singleton_class.define_method :generic_options do |ctx,**| { ** } end directive :generic_options, method(:generic_options) # FIXME: do we need this? end |