Sha256: 799d084b117ec675c772fa7a59c137b72b2294132d969edbc2b49de82f979ca9

Contents?: true

Size: 674 Bytes

Versions: 8

Compression:

Stored size: 674 Bytes

Contents

# from Demetrio Nunes
# Modified by Andy Singleton to use different GUID generator
#
# MIT License

require 'uuid22'

module ActiveRecord
  module Usesguid #:nodoc:
  
    def self.append_features(base)
      super
      base.extend(ClassMethods)  
    end

    
    module ClassMethods
      
      def usesguid(options = {})
                
        class_eval do
          set_primary_key options[:column] if options[:column]
          
          def after_initialize
            self.id ||= UUID.timestamp_create().to_s22
          end
        end        
        
      end
      
    end
  end
end

ActiveRecord::Base.class_eval do
  include ActiveRecord::Usesguid
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
parlement-0.10 vendor/plugins/guid/lib/usesguid.rb
parlement-0.3 vendor/plugins/guid/lib/usesguid.rb
parlement-0.4 vendor/plugins/guid/lib/usesguid.rb
parlement-0.5 vendor/plugins/guid/lib/usesguid.rb
parlement-0.6 vendor/plugins/guid/lib/usesguid.rb
parlement-0.7 vendor/plugins/guid/lib/usesguid.rb
parlement-0.8 vendor/plugins/guid/lib/usesguid.rb
parlement-0.9 vendor/plugins/guid/lib/usesguid.rb