Sha256: 02ef2b279b821b45f9f48da3a6ab19131f51699931cf64aca902a8f5d9349b4b

Contents?: true

Size: 455 Bytes

Versions: 4

Compression:

Stored size: 455 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

4 entries across 4 versions & 1 rubygems

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