module Logistics module Core class UnitService < BaseService def convert_unit(amount, abbreviation, to_base = true) rate = Unit.find_by(abbreviation: abbreviation).rate_to_base if rate to_base ? amount / rate : amount * rate else raise 'You have no unit conversion rate' end end end end end