Sha256: 8c84761b40a9a181cbe632d74700d8fd1f3171ca99a64e96a0c8156dd8f07597

Contents?: true

Size: 479 Bytes

Versions: 2

Compression:

Stored size: 479 Bytes

Contents

# frozen_string_literal: true

require "active_support" unless defined?(ActiveSupport)

module Lite
  module Uxid
    module Record
      module Ulid

        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::Ulid.encode
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lite-uxid-1.5.2 lib/lite/uxid/record/ulid.rb
lite-uxid-1.5.1 lib/lite/uxid/record/ulid.rb