Sha256: 0b7b86f71de3f5dfd286bb94b9f3901b6a6482038fe75c78ee189002fc6fe56e
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module Levtera::Concerns module Vehicle extend ActiveSupport::Concern ENGINE_FEEDINGS_NAMES = { car: %w(Gasolina Diesel Flex GNV Álcool Híbrido TetraFuel), motorcycle: %w(Gasolina Flex) } included do field :fabrication_year , type: Integer field :model_year , type: Integer field :plate , type: String field :engine_feeding , type: String belongs_to :version validates :fabrication_year , numericality: { only_integer: true, allow_nil: true, greater_than: 0 } validates :model_year , numericality: { only_integer: true, allow_nil: true, greater_than: 0 } # Only allowing nil because motorcycle sometimes comes with unknown feeding type validates :engine_feeding , inclusion: { in: -> (vehicle) { ENGINE_FEEDINGS_NAMES[vehicle.version.model.make.vehicle_type.to_sym] }, allow_nil: true } # TODO implement provider domain creation configuration method on include Provided # Provider data on an vehicle entity must be scoped within the # version field :provider_id , type: String field :provider , type: Symbol validates :provider_id, uniqueness: { allow_nil: true, scope: :version_id } validates :provider_id, uniqueness: { allow_nil: true, scope: :version_id } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
levtera-0.2.6 | lib/levtera/concerns/vehicle.rb |