Class: Culpa::BrickchainExecutor

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

Constant Summary collapse

@@injected_keywords =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(envelope, request) ⇒ BrickchainExecutor

Returns a new instance of BrickchainExecutor.



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

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, *args) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/culpa/brickchain_helpers.rb', line 27

def method_missing(sym, *args)
  if @@injected_keywords.has_key? sym
    method = @@injected_keywords[sym]
    instance_exec args, &method
  else
    CallHolder.new(sym.to_s, @envelope, @request)
  end
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

Class Method Details

.inject_keyword!(keyword, &call) ⇒ Object



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

def self.inject_keyword!(keyword, &call)
  @@injected_keywords[keyword] = call
end

Instance Method Details

#async(&blk) ⇒ Object



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

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

#eObject



23
24
25
# File 'lib/culpa/brickchain_helpers.rb', line 23

def e
  @envelope
end