Sha256: 8359dbe6ae46d3a5588436cb8cfb88d5b029fe923ba839faae7da5185784af5f
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
module DataMapper module Validate module Fixtures # for pedants: we refer to DIX Ethernet here class EthernetFrame # # Behaviors # include DataMapper::Resource # # Properties # attr_accessor :link_support_fragmentation # we have to have a key in a DM resource property :id, Serial without_auto_validations do property :destination_mac, String property :source_mac, String property :ether_type, String property :payload, Text property :crc, String end # # Validations # validates_length :destination_mac, :source_mac, :equals => 6 validates_length :ether_type, :equals => 2 validates_length :payload, :min => 46, :max => 1500, :unless => :link_support_fragmentation # :is is alias for :equal validates_length :crc, :is => 4 def self.valid_instance # these are obvisouly not bits, and not in hexadecimal # format either, but give fixture models some slack attributes = { :destination_mac => "7b7d93", :source_mac => "abe763", :ether_type => "88", :payload => "Imagine yourself a beautiful bag full of bits here", :crc => "4132" } new(attributes) end end # EthernetFrame end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dm-validations-0.10.2 | spec/fixtures/ethernet_frame.rb |
dm-validations-0.10.1 | spec/fixtures/ethernet_frame.rb |
dm-validations-0.10.0 | spec/fixtures/ethernet_frame.rb |