Sha256: ada7cef328c9d139475b50433ea5cd12ad1415ac49fb2d78b3e76d3a1c805137

Contents?: true

Size: 721 Bytes

Versions: 4

Compression:

Stored size: 721 Bytes

Contents

module StatusCat
  module Checkers
    class Base
      extend ActiveSupport::DescendantsTracker

      FORMAT = "%s | %s | %s\n"

      attr_reader :value, :status

      def self.class_to_name( klass )
        klass.to_s.split( '::' ).last.underscore.to_sym
      end

      def name
        Base.class_to_name( self.class )
        #self.class.to_s.split( '::' ).last.underscore.to_sym
      end

      def to_s( format = FORMAT )
        sprintf( format, name, value, status || I18n.t( :ok, :scope => :status_cat ) )
      end

    protected

      def fail_on_exception
        begin
          return yield
        rescue Exception => e
          return e
        end

        return nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
status_cat-0.1.1 lib/status_cat/checkers/base.rb
status_cat-0.1.0 lib/status_cat/checkers/base.rb
status_cat-0.0.9 lib/status_cat/checkers/base.rb
status_cat-0.0.8 lib/status_cat/checkers/base.rb