Class: Neo::DCI::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/neo/dci/context.rb

Direct Known Subclasses

Context

Defined Under Namespace

Classes: NoCallbackCalled

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#callbackObject

Returns the value of attribute callback


8
9
10
# File 'lib/neo/dci/context.rb', line 8

def callback
  @callback
end

Class Method Details

.call(*args, &block) ⇒ Object


16
17
18
19
20
21
22
23
# File 'lib/neo/dci/context.rb', line 16

def self.call(*args, &block)
  context = new(*args)
  context.callback = result_class.new(*callbacks, &block)
  context.call
  raise NoCallbackCalled, callbacks unless context.callback.called?
rescue NotImplementedError
  raise
end

.callbacks(*args) ⇒ Object


10
11
12
13
14
# File 'lib/neo/dci/context.rb', line 10

def self.callbacks(*args)
  @callbacks ||= []
  @callbacks = args unless args.empty?
  @callbacks
end

.result_class(klass = :reader) ⇒ Object


25
26
27
28
# File 'lib/neo/dci/context.rb', line 25

def self.result_class(klass = :reader)
  @result_class = klass unless klass == :reader
  defined?(@result_class) ? @result_class : ContextResult
end

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)

30
31
32
# File 'lib/neo/dci/context.rb', line 30

def call
  raise NotImplementedError
end