Class: Jet::Contract::Check::Set
- Inherits:
-
Object
- Object
- Jet::Contract::Check::Set
- Defined in:
- lib/jet/contract/check/set.rb
Instance Attribute Summary collapse
-
#checks ⇒ Object
readonly
Returns the value of attribute checks.
Instance Method Summary collapse
- #call(output) ⇒ Object
-
#initialize(*checks) ⇒ Set
constructor
A new instance of Set.
- #to_builder ⇒ Object
Constructor Details
#initialize(*checks) ⇒ Set
Returns a new instance of Set.
9 10 11 12 13 |
# File 'lib/jet/contract/check/set.rb', line 9 def initialize(*checks) @checks = [] checks.each { |c| add!(c) } @checks.freeze end |
Instance Attribute Details
#checks ⇒ Object (readonly)
Returns the value of attribute checks.
7 8 9 |
# File 'lib/jet/contract/check/set.rb', line 7 def checks @checks end |
Instance Method Details
#call(output) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/jet/contract/check/set.rb', line 15 def call(output) @checks.each do |(check, *args)| check.(output, *args).tap { |r| return r if Jet.failure?(r) } end Result.success(output) end |
#to_builder ⇒ Object
22 23 24 |
# File 'lib/jet/contract/check/set.rb', line 22 def to_builder @checks.map { |(c, *args)| [c.name].concat(args) } end |