Sha256: 0ddf68d0da30d918c05707968f7a0a638ea10c838452d08c81ae2a59790cddcd

Contents?: true

Size: 548 Bytes

Versions: 1

Compression:

Stored size: 548 Bytes

Contents

module Qrb
  module DataType

    def dress(value, handler = DressHelper.new)
      ad_type.dress(value, handler)
    end

    def contract(name, infotype)
      dresser   = method(name)
      undresser = instance_method(:"to_#{name}")
      ad_contracts[name] = [
        Qrb.type(infotype),
        dresser,
        ->(d){ undresser.bind(d).call }
      ]
    end

  private

    def ad_type
      @ad_type ||= Qrb.adt(self, ad_contracts)
    end

    def ad_contracts
      @ad_contracts ||= {}
    end

  end # module DataType
end # module Qrb

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qrb-0.3.0 lib/qrb/data_type.rb