lib/levtera/concerns/vehicle.rb in levtera-0.2.4 vs lib/levtera/concerns/vehicle.rb in levtera-0.2.5
- old
+ new
@@ -1,22 +1,26 @@
module Levtera::Concerns
module Vehicle
- ENGINE_FEEDINGS_NAMES = %i(gasoline alcohol diesel multifuel)
extend ActiveSupport::Concern
+ ENGINE_FEEDINGS_NAMES = {
+ car: %w(Gasolina Diesel Flex GNV Alcool Hibrido 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: Symbol
+ 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: ENGINE_FEEDINGS_NAMES, allow_nil: true }
+ 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