Class: BloodContracts::Core::Contract

Inherits:
Object
  • Object
show all
Defined in:
lib/blood_contracts/core/contract.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.input_typeObject

Returns the value of attribute input_type.



5
6
7
# File 'lib/blood_contracts/core/contract.rb', line 5

def input_type
  @input_type
end

.output_typeObject

Returns the value of attribute output_type.



5
6
7
# File 'lib/blood_contracts/core/contract.rb', line 5

def output_type
  @output_type
end

Class Method Details

.call(*args) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/blood_contracts/core/contract.rb', line 8

def self.call(*args)
  if (input_match = input_type.match(*args)).valid?
    result = yield(input_match)
    output_type.match(result, context: input_match.context)
  else
    input_match
  end
end