Sha256: 3512923d156714158e57647676af7e28d6c85b2be8d20876d859b076911f2b38

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

# -*- coding: utf-8 -*-

module DataMapper
  module Validate
    module Fixtures

      class UDPPacket
        #
        # Behaviors
        #

        include DataMapper::Resource

        #
        # Properties
        #

        property :id,          Serial

        property :source_port,      Integer, :auto_validation => false
        property :destination_port, Integer, :auto_validation => false

        property :length,           Integer, :auto_validation => false
        property :checksum,         String,  :auto_validation => false
        # consider that there are multiple algorithms
        # available to the app, and it is allowed
        # to be chosed
        #
        # yes, to some degree, this is a made up
        # property ;)
        property :checksum_algorithm, String, :auto_validation => false
        property :data,               Text,   :auto_validation => false

        #
        # Volatile attributes
        #

        attr_accessor :underlying_ip_version

        #
        # Validations
        #

        validates_present :checksum_algorithm, :checksum, :if => Proc.new { |packet| packet.underlying_ip_version == 6 }, :message => "Checksum is mandatory when used with IPv6"
      end

    end # Fixtures
  end # Validate
end # DataMapper

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dm-validations-0.10.2 spec/fixtures/udp_packet.rb
dm-validations-0.10.1 spec/fixtures/udp_packet.rb
dm-validations-0.10.0 spec/fixtures/udp_packet.rb