Sha256: 25e0a9b89409e101d79b16426ce5cc2ed9d4a094fb1b5e27503dc9bab9fdb8e4

Contents?: true

Size: 359 Bytes

Versions: 1

Compression:

Stored size: 359 Bytes

Contents

require "active_support/concern"

module WithUuid
  module Model

	  extend ActiveSupport::Concern

	  included do

      self.primary_key = :id

	    before_validation :set_id

	  end

    def set_id
      return unless id.blank?

      # Assign generated COMBination GUID to #id
      write_attribute( :id, WithUuid::CombUuid.uuid.to_s )
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
with_uuid-0.1.2 lib/with_uuid/model.rb