Sha256: 5ea412b5054db4fc5d1e1ddc78abe2dedb775fc71f464ac94f79955543b18d4a
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
## # VIN (Vehicle Identification Number) 是车辆识别码。 # https://en.wikipedia.org/wiki/Vehicle_identification_number # GB 16735-2004 module Unidom module ArticleNumber class VehicleIdentificationNumber < ApplicationRecord self.table_name = 'unidom_vehicle_identification_numbers' include Unidom::Common::Concerns::ModelExtension include Unidom::ArticleNumber::Concerns::AsBarcode validates :code, uniqueness: true, 'unidom/article_number/vehicle_identification_number': true validates :world_manufacturer_identifier, presence: true, length: { is: columns_hash['world_manufacturer_identifier'].limit } validates :vehicle_descriptor_section, presence: true, length: { is: columns_hash['vehicle_descriptor_section'].limit } validates :check_digit, presence: true, length: { is: columns_hash['check_digit'].limit } validates :vehicle_identifier_section, presence: true, length: { is: columns_hash['vehicle_identifier_section'].limit } def code=(code) code = code.to_s write_attribute :code, code if code.present? write_attribute :world_manufacturer_identifier, code[0..2] write_attribute :vehicle_descriptor_section, code[3..7] write_attribute :check_digit, code[8] write_attribute :vehicle_identifier_section, code[9..16] end end end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::ArticleNumber::VehicleIdentificationNumber' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-article_number-3.0.1 | app/models/unidom/article_number/vehicle_identification_number.rb |