Sha256: 69f53f678ac3d1ca035b7ee986f1be866bdada275753bad93480e2dd82efb08d
Contents?: true
Size: 880 Bytes
Versions: 2
Compression:
Stored size: 880 Bytes
Contents
module Finitio module Syntax module Contract def compile(factory, clazz) contract = [ type.compile(factory) ] + compile_pair(factory, clazz) { contract_name.to_sym => contract } end def compile_pair(factory, clazz) if pair pair.compile(factory) elsif clazz dresser = clazz.method(contract_name.to_sym) undresser = clazz.instance_method(:"to_#{contract_name}") [ dresser, ->(d){ undresser.bind(d).call } ] else [ Finitio::IDENTITY, Finitio::IDENTITY ] end end def to_ast ast = [ :contract, contract_name.to_s, (type && type.to_ast) ] ast << pair.to_ast if pair ast end end # module Contract end # module Syntax end # module Finitio
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
finitio-0.4.1 | lib/finitio/syntax/contract.rb |
finitio-0.4.0 | lib/finitio/syntax/contract.rb |