Sha256: ff984791be253776e1894b7c4644ceb66b22614bd3bfd476665231f5b378af6d

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

module God
  module Conditions
    # Always trigger or never trigger.
    #
    # Examples
    #
    #   # Always trigger.
    #   on.condition(:always) do |c|
    #     c.what = true
    #   end
    #
    #   # Never trigger.
    #   on.condition(:always) do |c|
    #     c.what = false
    #   end
    class Always < PollCondition
      # The Boolean determining whether this condition will always trigger
      # (true) or never trigger (false).
      attr_accessor :what

      def initialize
        super
        self.info = 'always'
      end

      def valid?
        valid = true
        valid &= complain("Attribute 'what' must be specified", self) if what.nil?
        valid
      end

      def test
        @what
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resurrected_god-1.1.1 lib/god/conditions/always.rb
resurrected_god-1.1.0 lib/god/conditions/always.rb