Module: DCI::Context::InstanceMethods

Defined in:
lib/dci/context.rb

Instance Method Summary collapse

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/dci/context.rb', line 44

def call
  raise NotImplementedError.new("implement me")
end

#context=(ctx) ⇒ Object



36
37
38
# File 'lib/dci/context.rb', line 36

def context=(ctx)
  Thread.current[:context] = ctx
end

#context_events=(ctx_events = []) ⇒ Object



40
41
42
# File 'lib/dci/context.rb', line 40

def context_events=(ctx_events = [])
  Thread.current[:context_events] = Array(ctx_events).compact.flatten
end

#perform_in_transactionObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dci/context.rb', line 16

def perform_in_transaction
  old_context = context
  old_context_events = context_events

  self.context = self
  self.context_events = []

  res = nil

  DCI.configuration.transaction_class.transaction do
    res = call
  end

  route_events!(context_events)
  res
ensure
  self.context = old_context
  self.context_events = old_context_events
end