Module: ActiveUUID::UUID::ClassMethods
- Defined in:
- lib/activeuuid/uuid.rb
Instance Method Summary collapse
- #instantiate_with_uuid(record, record_models = nil) ⇒ Object
- #natural_key(*attributes) ⇒ Object
- #uuid_columns ⇒ Object
- #uuid_generator(generator_name) ⇒ Object
- #uuid_namespace(namespace) ⇒ Object
- #uuids(*attributes) ⇒ Object
Instance Method Details
#instantiate_with_uuid(record, record_models = nil) ⇒ Object
131 132 133 134 135 136 |
# File 'lib/activeuuid/uuid.rb', line 131 def instantiate_with_uuid(record, record_models = nil) uuid_columns.each do |uuid_column| record[uuid_column] = UUIDTools::UUID.serialize(record[uuid_column]).to_s if record[uuid_column] end instantiate_without_uuid(record) end |
#natural_key(*attributes) ⇒ Object
111 112 113 |
# File 'lib/activeuuid/uuid.rb', line 111 def natural_key(*attributes) self._natural_key = attributes end |
#uuid_columns ⇒ Object
138 139 140 |
# File 'lib/activeuuid/uuid.rb', line 138 def uuid_columns @uuid_columns ||= columns.select { |c| c.type == :uuid }.map(&:name) end |
#uuid_generator(generator_name) ⇒ Object
120 121 122 |
# File 'lib/activeuuid/uuid.rb', line 120 def uuid_generator(generator_name) self._uuid_generator = generator_name end |
#uuid_namespace(namespace) ⇒ Object
115 116 117 118 |
# File 'lib/activeuuid/uuid.rb', line 115 def uuid_namespace(namespace) namespace = UUIDTools::UUID.parse_string(namespace) unless namespace.is_a? UUIDTools::UUID self._uuid_namespace = namespace end |
#uuids(*attributes) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/activeuuid/uuid.rb', line 124 def uuids(*attributes) ActiveSupport::Deprecation.warn <<-EOS ActiveUUID detects uuid columns independently. There is no more need to use uuid method. EOS end |