module StartHer::Utils

Public Instance Methods

fingerprint(*args) click to toggle source
# File lib/start_her/utils.rb, line 12
def fingerprint(*args)
  args ||= []
  [Socket.gethostname, service_klass].concat(args).map(&:to_s).join('')
end
msid(*args) click to toggle source
# File lib/start_her/utils.rb, line 3
def msid(*args)
  if StartHer.env == 'development'
    # Easy understanding identifier in development environment
    "#{args.first || service_klass}:#{object_id}"
  else
    Digest::SHA256.hexdigest(fingerprint(*args))
  end
end
service_klass() click to toggle source

If the current class is `MyService::Subscriber' It returns `MyService' object

# File lib/start_her/utils.rb, line 19
def service_klass
  if (klass = Object.const_get(self.class.name.split('::').first)) == StartHer
    # Find the class name of the caller if `klass' is StartHer
    binding.receiver.class.name.split('::').first
  else
    klass
  end
end