Class: BCDD::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/bcdd/process.rb,
lib/bcdd/process/output.rb,
lib/bcdd/process/version.rb

Defined Under Namespace

Modules: Output

Constant Summary collapse

VERSION =
'0.4.0'

Class Method Summary collapse

Class Method Details

.call(**input) ⇒ Object



53
54
55
# File 'lib/bcdd/process.rb', line 53

def self.call(**input)
  new.call(**input)
end

.inherited(subclass) ⇒ Object



49
50
51
# File 'lib/bcdd/process.rb', line 49

def self.inherited(subclass)
  subclass.prepend(Caller)
end

.input(&block) ⇒ Object



25
26
27
28
29
# File 'lib/bcdd/process.rb', line 25

def self.input(&block)
  return if const_defined?(:Input)

  const_set(:Input, ::BCDD::Data.new(&block))
end

.output(expectations: true, &block) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bcdd/process.rb', line 33

def self.output(expectations: true, &block)
  return if const_defined?(:Result, false)

  if expectations
    evaluator = Output::Evaluator.new
    evaluator.instance_eval(&block)

    success = evaluator.__properties__.success
    failure = evaluator.__properties__.failure

    include(Result::Context::Expectations.mixin(config: RESULT_CONFIG, success: success, failure: failure))
  else
    include(Result::Context.mixin(config: RESULT_CONFIG))
  end
end