Class: Kanal::Core::Helpers::ResponseBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/kanal/core/helpers/response_block.rb

Overview

Response block stores block of code to be executed at runtime and output to be created

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, async: false, functional: false) ⇒ ResponseBlock

Creates response block that stores block for evaluation at runtime, when output is constructed

Parameters:

  • block (Proc)

    block of code to be evaluated at runtime and output to be constructed with it

  • async (Boolean) (defaults to: false)

    block should be executed in thread

  • functional (Boolean) (defaults to: false)

    block should be executed but not shipped as outpu



21
22
23
24
25
# File 'lib/kanal/core/helpers/response_block.rb', line 21

def initialize(block, async: false, functional: false)
  @block = block
  @async = async
  @functional = functional
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



11
12
13
# File 'lib/kanal/core/helpers/response_block.rb', line 11

def block
  @block
end

Instance Method Details

#async?Boolean

Should execution of block be async?

Returns:

  • (Boolean)

    <description>



42
43
44
# File 'lib/kanal/core/helpers/response_block.rb', line 42

def async?
  @async
end

#functional?Boolean

Whether response block is functional, means no output should be processed after execution of block

Returns:

  • (Boolean)

    <description>



33
34
35
# File 'lib/kanal/core/helpers/response_block.rb', line 33

def functional?
  @functional
end