Class: Trailblazer::Endpoint::DSL::Runtime

Inherits:
Struct
  • Object
show all
Defined in:
lib/trailblazer/endpoint/dsl.rb

Overview

Run before the endpoint is invoked. This collects the blocks from the controller.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#failure_blockObject

Returns the value of attribute failure_block

Returns:

  • (Object)

    the current value of failure_block



5
6
7
# File 'lib/trailblazer/endpoint/dsl.rb', line 5

def failure_block
  @failure_block
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



5
6
7
# File 'lib/trailblazer/endpoint/dsl.rb', line 5

def options
  @options
end

#protocol_failure_blockObject

Returns the value of attribute protocol_failure_block

Returns:

  • (Object)

    the current value of protocol_failure_block



5
6
7
# File 'lib/trailblazer/endpoint/dsl.rb', line 5

def protocol_failure_block
  @protocol_failure_block
end

#success_blockObject

Returns the value of attribute success_block

Returns:

  • (Object)

    the current value of success_block



5
6
7
# File 'lib/trailblazer/endpoint/dsl.rb', line 5

def success_block
  @success_block
end

Instance Method Details

#failure(&block) ⇒ Object Also known as: Or



7
8
9
10
# File 'lib/trailblazer/endpoint/dsl.rb', line 7

def failure(&block)
  self.failure_block = block
  self
end

#protocol_failure(&block) ⇒ Object



14
15
16
17
# File 'lib/trailblazer/endpoint/dsl.rb', line 14

def protocol_failure(&block)
  self.protocol_failure_block = block
  self
end

#to_args(default_block_options) ⇒ Object

#call



20
21
22
23
24
25
26
27
# File 'lib/trailblazer/endpoint/dsl.rb', line 20

def to_args(default_block_options)
  return options,
  default_block_options.merge( # this adds :invoke.
    success_block:          success_block || default_block_options[:success_block],
    failure_block:          failure_block || default_block_options[:failure_block],
    protocol_failure_block: protocol_failure_block || default_block_options[:protocol_failure_block]
  )
end