Sha256: df8f24065391ad24acc87ee95b26c439033bbc1bec4852c90123704ce9faa0d1

Contents?: true

Size: 351 Bytes

Versions: 55

Compression:

Stored size: 351 Bytes

Contents

module Agilibox::ActiveRecordUUIDConcern
  extend ActiveSupport::Concern

  private

  def assign_default_uuid
    unless self.class.columns_hash["id"].type == :uuid
      raise "invalid id type, please change to uuid"
    end

    self.id ||= ::Agilibox::SortableUUIDGenerator.call
  end

  included do
    before_save :assign_default_uuid
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
agilibox-1.5.8 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.5.7 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.5.6 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.5.5 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.5.4 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.5.3 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.5.2 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.5.1 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.5.0 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.4.4 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.4.3 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.4.2 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.4.1 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.4.0 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.3.6 app/models/concerns/agilibox/active_record_uuid_concern.rb