From 7c4cf106c73c5f114d9f0f2c65d558ba6a9c9c87 Mon Sep 17 00:00:00 2001 From: Nicolas Rodriguez Date: Wed, 13 Mar 2019 05:30:16 +0100 Subject: [PATCH] Coding style --- lib/health_monitor/providers/base.rb | 42 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/lib/health_monitor/providers/base.rb b/lib/health_monitor/providers/base.rb index d59b2bb..0c0fcb2 100644 --- a/lib/health_monitor/providers/base.rb +++ b/lib/health_monitor/providers/base.rb @@ -3,27 +3,39 @@ module HealthMonitor module Providers class Base - attr_reader :request + + attr_reader :request attr_accessor :configuration - def self.provider_name - @provider_name ||= name.demodulize + def initialize(request: nil) + @request = request + + return unless self.class.configurable? + + self.configuration = self.class.instance_variable_get('@global_configuration') end - def self.configure - return unless configurable? + class << self - @global_configuration = configuration_class.new + def provider_name + @provider_name ||= name.demodulize + end - yield @global_configuration if block_given? - end + def configure + return unless configurable? - def initialize(request: nil) - @request = request + @global_configuration = configuration_class.new - return unless self.class.configurable? + yield @global_configuration if block_given? + end + + def configurable? + configuration_class + end + + def configuration_class + end - self.configuration = self.class.instance_variable_get('@global_configuration') end # @abstract @@ -31,12 +43,6 @@ def check! raise NotImplementedError end - def self.configurable? - configuration_class - end - - # @abstract - def self.configuration_class; end end end end