Sha256: d9e91385f34399cb3eee502826df5cdf50c43f4692e5a46d5b0c939f20fced7a

Contents?: true

Size: 992 Bytes

Versions: 10

Compression:

Stored size: 992 Bytes

Contents

require 'rocket_fuel/precheck'
require 'rocket_fuel/precheck/check_result'

module RocketFuel
  module Precheck
    class Check
      def ok?
        virtual_method(:ok?)
      end

      def run
        CheckResult.new(ok?, message, self.class.check_name_value)
      end

      def check?
        true
      end

      def message
        ok? ? success_message : failure_message
      end

      class << self
        def check_name(sym)
          @check_name = sym
        end

        def check_name_value
          @check_name
        end

        def register!
          RocketFuel::Precheck.register_check(self)
        end
      end

      protected
      def success_message
        virtual_method(:success_message)
      end

      def failure_message
        virtual_method(:failure_message)
      end

      def virtual_method(method_name)
        raise RocketFuel::NotImplementedError,
          "you must override the `#{method_name}` in your check"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rocket_fuel-0.2.0 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.1.0 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.0.8 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.0.7 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.0.6 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.0.5 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.0.4 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.0.3 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.0.2 lib/rocket_fuel/precheck/check.rb
rocket_fuel-0.0.1 lib/rocket_fuel/precheck/check.rb