Class: BCDD::Process
- Inherits:
-
Object
- Object
- BCDD::Process
- Defined in:
- lib/bcdd/process.rb,
lib/bcdd/process/caller.rb,
lib/bcdd/process/version.rb,
lib/bcdd/process/input_spec.rb,
lib/bcdd/process/output_spec.rb
Defined Under Namespace
Modules: Caller Classes: InputSpec, OutputSpec
Constant Summary collapse
- VERSION =
'0.3.0'
Class Attribute Summary collapse
-
.__input__ ⇒ Object
readonly
Returns the value of attribute __input__.
-
.__input_contract__ ⇒ Object
readonly
Returns the value of attribute input_contract.
-
.__output__ ⇒ Object
readonly
Returns the value of attribute __output__.
Class Method Summary collapse
- .call(**input) ⇒ Object
- .inherited(subclass) ⇒ Object
- .input(&block) ⇒ Object
- .output(expectations: true, &block) ⇒ Object
Class Attribute Details
.__input__ ⇒ Object (readonly)
Returns the value of attribute __input__.
17 18 19 |
# File 'lib/bcdd/process.rb', line 17 def __input__ @__input__ end |
.__input_contract__ ⇒ Object (readonly)
Returns the value of attribute input_contract.
17 18 19 |
# File 'lib/bcdd/process.rb', line 17 def __input_contract__ @__input_contract__ end |
.__output__ ⇒ Object (readonly)
Returns the value of attribute __output__.
17 18 19 |
# File 'lib/bcdd/process.rb', line 17 def __output__ @__output__ end |
Class Method Details
.call(**input) ⇒ Object
55 56 57 |
# File 'lib/bcdd/process.rb', line 55 def call(**input) new.call(**input) end |
.inherited(subclass) ⇒ Object
51 52 53 |
# File 'lib/bcdd/process.rb', line 51 def inherited(subclass) subclass.prepend(Caller) end |
.input(&block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bcdd/process.rb', line 19 def input(&block) return @__input__ if defined?(@__input__) spec = InputSpec.new spec.instance_eval(&block) spec.__result__.transform_values!(&:freeze).freeze @__input_contract__ = spec.__result__.any? { |_key, value| value.key?(:contract) } @__input__ = spec.__result__ end |
.output(expectations: true, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bcdd/process.rb', line 30 def output(expectations: true, &block) @__output__ and raise ArgumentError, 'outputs already defined' config = { addon: { given: true, continue: true } } if expectations spec = OutputSpec.new spec.instance_eval(&block) output = spec.__result__ success = output[:success] failure = output.fetch(:failure, {}).merge(invalid_input: ::Hash) include(Result::Context::Expectations.mixin(config: config, success: success, failure: failure)) else include(Result::Context.mixin(config: config)) end @__output__ = { expectations: expectations }.freeze end |