diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4a12379922..5812142f9c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -16,7 +16,7 @@ Metrics/BlockNesting: # Offense count: 4 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 246 + Max: 252 # Offense count: 23 Metrics/CyclomaticComplexity: diff --git a/lib/grape/endpoint.rb b/lib/grape/endpoint.rb index e06c96be17..e4f909e994 100644 --- a/lib/grape/endpoint.rb +++ b/lib/grape/endpoint.rb @@ -217,7 +217,7 @@ def equals?(e) protected def run(env) - instrument("run.grape", endpoint: self, env: env) do + instrument('run.grape', endpoint: self, env: env) do @env = env @header = {} diff --git a/lib/grape/instrumentable.rb b/lib/grape/instrumentable.rb index f304b97f5a..5596517f89 100644 --- a/lib/grape/instrumentable.rb +++ b/lib/grape/instrumentable.rb @@ -1,16 +1,10 @@ module Grape module Instrumentable - @@instrumenter = nil - - def self.instrumenter - @@instrumenter - end - - def self.instrumenter=(val) - @@instrumenter = val + class << self + attr_accessor :instrumenter end - def instrument(name, payload={}) + def instrument(name, payload = {}) if Instrumentable.instrumenter Instrumentable.instrumenter(name, payload) { yield payload if block_given? } else @@ -18,4 +12,4 @@ def instrument(name, payload={}) end end end -end \ No newline at end of file +end