Class: Uuidify::Uuid
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Uuidify::Uuid
- Defined in:
- app/models/uuidify/uuid.rb
Overview
Store the relationship between UUID and ActiveRecord instance
Class Method Summary collapse
- .uuid_from_sql_string(string) ⇒ Object
- .uuid_storage_type ⇒ Object
- .uuid_to_sql_string(uuid) ⇒ Object
Class Method Details
.uuid_from_sql_string(string) ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/models/uuidify/uuid.rb', line 19 def self.uuid_from_sql_string string if uuid_storage_type == :string UUIDTools::UUID.parse(string) else UUIDTools::UUID.parse_raw(string) end end |
.uuid_storage_type ⇒ Object
7 8 9 |
# File 'app/models/uuidify/uuid.rb', line 7 def self.uuid_storage_type connection.adapter_name == "PostgreSQL" ? :string : :binary end |
.uuid_to_sql_string(uuid) ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/models/uuidify/uuid.rb', line 11 def self.uuid_to_sql_string uuid if uuid_storage_type == :string uuid.to_s else uuid.raw end end |