Sha256: 57447d31e3a3232ac554dd1e1c2d11ead7d29b277fecfb9e45fdb77b0d269c74

Contents?: true

Size: 564 Bytes

Versions: 9

Compression:

Stored size: 564 Bytes

Contents

module Logistics
  module Core
    class Client < ApplicationRecord
      VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

      validates :name, presence: true
      validates :email, format: { with: VALID_EMAIL_REGEX }
      belongs_to :country
      belongs_to :client_category

      delegate(:name, to: :country, prefix: true, allow_nil: true)
      delegate(:name, to: :client_category, prefix: true, allow_nil: true)

      before_save { email.downcase! }

      def self.build(options = {})
        Client.new(options)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 app/models/logistics/core/client.rb
logistics_core-21.11.1 app/models/logistics/core/client.rb
logistics_core-21.08.1 app/models/logistics/core/client.rb
logistics_core-21.03.1 app/models/logistics/core/client.rb
logistics_core-20.10.3 app/models/logistics/core/client.rb
logistics_core-20.10.2 app/models/logistics/core/client.rb
logistics_core-20.10.1 app/models/logistics/core/client.rb
logistics_core-20.9.1 app/models/logistics/core/client.rb
logistics_core-20.8.1 app/models/logistics/core/client.rb