Class: RailsDbLocalize::Translation

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/rails_db_localize/translation.rb

Class Method Summary collapse

Class Method Details

.generate_ck(resource_type, resource_id) ⇒ Object



19
20
21
22
23
24
25
26
# File 'app/models/rails_db_localize/translation.rb', line 19

def self.generate_ck resource_type, resource_id
  hash_long = [resource_type.to_s.underscore, resource_id].join("|").chars.map(&:ord).inject(5381) do |h, v|
    h += ((h<<5)+h)+v
  end

  #Keep it signed 32bits.
  hash_long & 0x7fffffff
end