Module: StartHer::Utils
- Included in:
- Heartbeat, Subscriber
- Defined in:
- lib/start_her/utils.rb
Instance Method Summary collapse
- #fingerprint(*args) ⇒ Object
- #msid(*args) ⇒ Object
-
#service_klass ⇒ Object
If the current class is ‘MyService::Subscriber’ It returns ‘MyService’ object.
Instance Method Details
#fingerprint(*args) ⇒ Object
12 13 14 15 |
# 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) ⇒ Object
3 4 5 6 7 8 9 10 |
# 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 ⇒ Object
If the current class is ‘MyService::Subscriber’ It returns ‘MyService’ object
19 20 21 22 23 24 25 26 |
# 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 |