Sha256: 1bc781863572049d8bdff0ad7fcc93924fe2664041b1a9e47ea99d911006c96a

Contents?: true

Size: 775 Bytes

Versions: 6

Compression:

Stored size: 775 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    module PostgreSQL
      module OID # :nodoc:
        class Uuid < Type::Value # :nodoc:
          RFC_4122 = %r{\A\{?[a-fA-F0-9]{4}-?
                             [a-fA-F0-9]{4}-?
                             [a-fA-F0-9]{4}-?
                             [1-5][a-fA-F0-9]{3}-?
                             [8-Bab][a-fA-F0-9]{3}-?
                             [a-fA-F0-9]{4}-?
                             [a-fA-F0-9]{4}-?
                             [a-fA-F0-9]{4}-?\}?\z}x

          alias_method :type_cast_for_database, :type_cast_from_database

          def type
            :uuid
          end

          def type_cast(value)
            value.to_s[RFC_4122, 0]
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-4.2.0.rc3 lib/active_record/connection_adapters/postgresql/oid/uuid.rb
activerecord-4.2.0.rc2 lib/active_record/connection_adapters/postgresql/oid/uuid.rb
activerecord-4.2.0.rc1 lib/active_record/connection_adapters/postgresql/oid/uuid.rb
activerecord-4.2.0.beta4 lib/active_record/connection_adapters/postgresql/oid/uuid.rb
activerecord-4.2.0.beta3 lib/active_record/connection_adapters/postgresql/oid/uuid.rb
activerecord-4.2.0.beta2 lib/active_record/connection_adapters/postgresql/oid/uuid.rb