56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/ar_sync/core.rb', line 56
def self.sync_key(model, to_user = nil, signature: true)
if model.is_a? ArSync::Collection
key = [to_user&.id, model.klass.name, model.name].join '/'
else
key = [to_user&.id, model.class.name, model.id].join '/'
end
key = Digest::SHA256.hexdigest("#{config.key_secret}#{key}")[0, 32] if config.key_secret
key = "#{config.key_prefix}#{key}" if config.key_prefix
key = signature && config.key_expires_in ? signed_key(key, Time.now.to_i.to_s) : key
key + ';/'
end
|