Sha256: 845be0501740a834452c430ec922be548c17f2f6f583eee59db92c6f91d9e784

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

module Flipper
  module Gates
    class Boolean < Gate
      # Internal: The name of the gate. Used for instrumentation, etc.
      def name
        :boolean
      end

      # Internal: The piece of the adapter key that is unique to the gate class.
      def key
        :boolean
      end

      # Internal: The toggle class used to enable/disable the gate for a thing.
      def toggle_class
        Toggles::Boolean
      end

      # Internal: Checks if the gate is open for a thing.
      #
      # Returns true if gate open for thing, false if not.
      def open?(thing)
        instrument(:open?, thing) { |payload| toggle.value }
      end

      def protects?(thing)
        thing.is_a?(Flipper::Types::Boolean)
      end

      def description
        if enabled?
          'Enabled'
        else
          'Disabled'
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flipper-0.4.0 lib/flipper/gates/boolean.rb