Sha256: e1fa9411ada64595b2a1678a04183255a0e69c8917700121bf395593818c41c7

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module Workarea
  module Admin
    class CircuitViewModel < ApplicationViewModel
      def name
        model.name.to_s.humanize
      end

      def slug
        model.name
      end

      def current_fails
        timeline.length
      end

      def broken_until
        return unless options[:broken_until].present?

        Time.at(options[:broken_until].to_i)
      end

      def healthy?
        options[:broken_until].blank?
      end

      def timeline
        @timeline ||= options.fetch(:timeline, []).map do |(failure_string, timestamp)|
          CircuitBreaker::FailureMessage.from_string(failure_string, Time.at(timestamp))
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-circuit_breaker-1.0.3 app/view_models/workarea/admin/circuit_view_model.rb