Sha256: 6c4a04d190dd73d1fc3f6506689227fd5892641f26af4733881d1b25b1eb2c42

Contents?: true

Size: 455 Bytes

Versions: 3

Compression:

Stored size: 455 Bytes

Contents

# frozen_string_literal: true

require "active_support" unless defined?(ActiveSupport)

module Lite
  module Uxid
    module Record
      module Uuid

        extend ActiveSupport::Concern

        included do
          before_create :callback_generate_uxid!, if: proc { respond_to?(:uxid) && !uxid? }
        end

        private

        def callback_generate_uxid!
          self.uxid = Lite::Uxid::Uuid.encode
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lite-uxid-1.5.0 lib/lite/uxid/record/uuid.rb
lite-uxid-1.4.0 lib/lite/uxid/record/uuid.rb
lite-uxid-1.3.0 lib/lite/uxid/record/uuid.rb