Class: BCDD::Process::InputSpec
- Inherits:
-
Object
- Object
- BCDD::Process::InputSpec
- Defined in:
- lib/bcdd/process/input_spec.rb
Defined Under Namespace
Modules: MapContract
Constant Summary collapse
- MapDefault =
->() do value = [:default] return value unless value.is_a?(Proc) return value if value.lambda? && value.arity.zero? raise ArgumentError, 'Default value must be a lambda with zero arity' end
- MapNormalize =
->() do value = [:normalize] return value if value.is_a?(Proc) && value.lambda? raise ArgumentError, 'normalize value must be a lambda with one arity' end
Instance Attribute Summary collapse
-
#__result__ ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #attribute(name, **options) ⇒ Object
- #contract ⇒ Object
-
#initialize ⇒ InputSpec
constructor
A new instance of InputSpec.
Constructor Details
#initialize ⇒ InputSpec
Returns a new instance of InputSpec.
45 46 47 |
# File 'lib/bcdd/process/input_spec.rb', line 45 def initialize @__result__ = {} end |
Instance Attribute Details
#__result__ ⇒ Object (readonly)
:nodoc:
43 44 45 |
# File 'lib/bcdd/process/input_spec.rb', line 43 def __result__ @__result__ end |
Instance Method Details
#attribute(name, **options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/bcdd/process/input_spec.rb', line 49 def attribute(name, **) name.is_a?(Symbol) or raise ArgumentError, "#{name.inspect} must be a Symbol" spec = {} spec[:default] = MapDefault[] if .key?(:default) spec[:normalize] = MapNormalize[] if .key?(:normalize) MapContract[].then { spec[:contract] = _1 if _1 } __result__[name] = spec end |