Method: Finitio::Contract#initialize

Defined in:
lib/finitio/support/contract.rb

#initialize(infotype, dresser, undresser, name = nil, metadata = nil) ⇒ Contract

Returns a new instance of Contract.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/finitio/support/contract.rb', line 5

def initialize(infotype, dresser, undresser, name = nil,  = nil)
  unless infotype.is_a?(Type)
    raise ArgumentError, "Type expected, got `#{infotype}`"
  end
  unless dresser.respond_to?(:call)
    raise ArgumentError, "r(:call) expected, got `#{dresser}`"
  end
  unless undresser.respond_to?(:call)
    raise ArgumentError, "r(:call) expected, got `#{undresser}`"
  end
  unless name.nil? or name.is_a?(Symbol)
    raise ArgumentError, "Symbol expected, got `#{name}`"
  end

  @name      = name
  @infotype  = infotype
  @dresser   = dresser
  @undresser = undresser
    = 
end