Sha256: 0c66fd5cf11065678fffd3598d763c709833ac7df2d3de46ecb0f314e1dffc93

Contents?: true

Size: 339 Bytes

Versions: 19

Compression:

Stored size: 339 Bytes

Contents

module BMC::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 ||= BMC::SortableUUIDGenerator.call
  end

  included do
    before_save :assign_default_uuid
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bmc-1.6.1 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.6.0 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.5.1 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.5.0 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.4.3 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.4.2 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.4.1 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.4.0 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.3.5 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.3.4 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.3.3 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.3.2 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.3.1 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.3.0 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.2.1 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.2.0 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.1.0 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.0.1 app/models/concerns/bmc/active_record_uuid_concern.rb
bmc-1.0.0 app/models/concerns/bmc/active_record_uuid_concern.rb