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-2.0.0 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.11.0 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.10.5 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.10.2 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.10.1 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.10.0 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.20 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.19 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.18 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.17 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.16 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.15 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.14 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.13 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.12 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.11 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.10 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.9 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.8 app/models/concerns/agilibox/active_record_uuid_concern.rb
agilibox-1.9.7 app/models/concerns/agilibox/active_record_uuid_concern.rb