Sha256: c1767af523bbb3e05362668d83df5a210caa56d6d4dcf6f2e0d2664744200ae7

Contents?: true

Size: 873 Bytes

Versions: 20

Compression:

Stored size: 873 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.boolean
      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

20 entries across 20 versions & 1 rubygems

Version Path
flipper-1.3.2 lib/flipper/gates/boolean.rb
flipper-1.3.1 lib/flipper/gates/boolean.rb
flipper-1.3.0 lib/flipper/gates/boolean.rb
flipper-1.3.0.pre lib/flipper/gates/boolean.rb
flipper-1.2.2 lib/flipper/gates/boolean.rb
flipper-1.2.1 lib/flipper/gates/boolean.rb
flipper-1.2.0 lib/flipper/gates/boolean.rb
flipper-1.1.2 lib/flipper/gates/boolean.rb
flipper-1.1.1 lib/flipper/gates/boolean.rb
flipper-1.1.0 lib/flipper/gates/boolean.rb
flipper-1.0.0 lib/flipper/gates/boolean.rb
flipper-1.0.0.pre lib/flipper/gates/boolean.rb
flipper-0.28.3 lib/flipper/gates/boolean.rb
flipper-0.28.2 lib/flipper/gates/boolean.rb
flipper-0.28.1 lib/flipper/gates/boolean.rb
flipper-0.28.0 lib/flipper/gates/boolean.rb
flipper-0.27.1 lib/flipper/gates/boolean.rb
flipper-0.27.0 lib/flipper/gates/boolean.rb
flipper-0.26.2 lib/flipper/gates/boolean.rb
flipper-0.26.1 lib/flipper/gates/boolean.rb