about summary refs log tree commit diff
path: root/app/helpers/application_helper.rb
blob: e683d9f517af993292f7a82861dc1c2a45d799b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module ApplicationHelper
  def unique_tag(date, id, type)
    "tag:#{Rails.configuration.x.local_domain},#{date.strftime('%Y-%m-%d')}:objectId=#{id}:objectType=#{type}"
  end

  def unique_tag_to_local_id(tag, expected_type)
    matches = Regexp.new("objectId=([\\d]+):objectType=#{expected_type}").match(tag)
    return matches[1] unless matches.nil?
  end

  def local_id?(id)
    id.start_with?("tag:#{Rails.configuration.x.local_domain}")
  end
end