Sha256: 41bcb627a3cd0bc4be5ee1cda78ff16d0b86219ade4e7eedbdc25cc58b65441f

Contents?: true

Size: 870 Bytes

Versions: 54

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: Name converted to value safe for adapter.
      def key
        :boolean
      end

      def data_type
        :boolean
      end

      def enabled?(value)
        !!value
      end

      # Internal: Checks if the gate is open for a thing.
      #
      # Returns true if explicitly set to true, false if explicitly set to false
      # or nil if not explicitly set.
      def open?(context)
        context.values[key]
      end

      def wrap(thing)
        Types::Boolean.wrap(thing)
      end

      def protects?(thing)
        case thing
        when Types::Boolean, TrueClass, FalseClass
          true
        else
          false
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
flipper-0.20.2 lib/flipper/gates/boolean.rb
flipper-0.20.1 lib/flipper/gates/boolean.rb
flipper-0.20.0 lib/flipper/gates/boolean.rb
flipper-0.20.0.beta3 lib/flipper/gates/boolean.rb
flipper-0.20.0.beta2 lib/flipper/gates/boolean.rb
flipper-0.20.0.beta1 lib/flipper/gates/boolean.rb
flipper-0.19.1 lib/flipper/gates/boolean.rb
flipper-0.19.0 lib/flipper/gates/boolean.rb
flipper-0.18.0 lib/flipper/gates/boolean.rb
flipper-0.17.2 lib/flipper/gates/boolean.rb
flipper-0.17.1 lib/flipper/gates/boolean.rb
flipper-0.16.2 lib/flipper/gates/boolean.rb
flipper-0.16.1 lib/flipper/gates/boolean.rb
flipper-0.16.0 lib/flipper/gates/boolean.rb
flipper-0.15.0 lib/flipper/gates/boolean.rb
flipper-0.14.0 lib/flipper/gates/boolean.rb
flipper-0.13.0 lib/flipper/gates/boolean.rb
flipper-0.13.0.beta1 lib/flipper/gates/boolean.rb
flipper-0.12.2 lib/flipper/gates/boolean.rb
flipper-0.12.1 lib/flipper/gates/boolean.rb