Sha256: ed6d883014d41c5bb94ae51c2e1d23289edd62cb3c8fa10fa5b737f3cd977f15
Contents?: true
Size: 602 Bytes
Versions: 3
Compression:
Stored size: 602 Bytes
Contents
# frozen_string_literal: true class ServiceSkeleton module MetricsMethods def service=(svc) @service = svc end def register(metric) method_name = metric.name.to_s.gsub(/\A#{Regexp.quote(@service.service_name)}_/, '').to_sym if self.class.method_defined?(method_name) raise ServiceSkeleton::Error::InvalidMetricNameError, "There is already a method named #{method_name} on ##metrics, so you can't have a metric named #{metric.name}" end define_singleton_method(method_name) do metric end super end end end
Version data entries
3 entries across 3 versions & 1 rubygems