Class: Culpa::BrickchainExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/culpa/brickchain_helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(envelope, request) ⇒ BrickchainExecutor

Returns a new instance of BrickchainExecutor.



6
7
8
9
# File 'lib/culpa/brickchain_helpers.rb', line 6

def initialize(envelope, request)
  @envelope = envelope
  @request = request
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym) ⇒ Object



29
30
31
# File 'lib/culpa/brickchain_helpers.rb', line 29

def method_missing(sym)
  CallHolder.new(sym.to_s, @envelope, @request)
end

Instance Attribute Details

#envelopeObject (readonly)

Returns the value of attribute envelope.



4
5
6
# File 'lib/culpa/brickchain_helpers.rb', line 4

def envelope
  @envelope
end

Instance Method Details

#async(&blk) ⇒ Object



11
12
13
14
15
# File 'lib/culpa/brickchain_helpers.rb', line 11

def async(&blk)
  asb = AsyncBrickchain.new(@envelope, @request)
  asb.instance_eval(&blk)
  asb.chs.each { |call_holder| call_holder.thread.join }
end

#eObject



17
18
19
# File 'lib/culpa/brickchain_helpers.rb', line 17

def e
  @envelope
end

#render_coliseum(file) ⇒ Object

Raises:



21
22
23
24
25
26
27
# File 'lib/culpa/brickchain_helpers.rb', line 21

def render_coliseum(file)
  coliseum = ColiseumDSL.new("./coliseums/#{file}.rb", envelope)
  raise Action::RenderNow, format: :json,
                           status: RendererDescriber::RETURN_CODES[coliseum.culpa_status] || 200,
                           headers: { 'Content-Type' => 'application/json' }.merge(coliseum.culpa_headers),
                           object: coliseum.dsl_attributes
end