Module: NamedSeeds::DSL

Included in:
NamedSeeds
Defined in:
lib/named_seeds/dsl.rb

Constant Summary collapse

MAX_ID =
2 ** 30 - 1

Instance Method Summary collapse

Instance Method Details

#identify(label, column_type = :integer) ⇒ Object Also known as: id

Copy of ActiveRecord::Fixtures.identify method. Returns a consistent, platform-independent identifier for label. Integer identifiers are values less than 2^30. UUIDs are RFC 4122 version 5 SHA-1 hashes.



13
14
15
16
17
18
19
# File 'lib/named_seeds/dsl.rb', line 13

def identify(label, column_type = :integer)
  if column_type == :uuid
    NamedSeeds.uuid_v5(label)
  else
    Zlib.crc32(label.to_s) % MAX_ID
  end
end