Sha256: 62d6b9767cd2873e355f8b16077018cc4b1d92b58ef2cff02f5f0835d457cf32

Contents?: true

Size: 392 Bytes

Versions: 1

Compression:

Stored size: 392 Bytes

Contents

require "active_support/concern"

module WithUuid
  module Model

	  extend ActiveSupport::Concern

	  included do

      self.primary_key = :id

      before_validation :set_id
      before_create     :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.2.0 lib/with_uuid/model.rb