Sha256: 430734ccadeb0fff1af4cc72483ca21910c5799521388a2d42ec19665ab3c2e8

Contents?: true

Size: 894 Bytes

Versions: 10

Compression:

Stored size: 894 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)
        Typecast.to_boolean(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?(thing, value, options = {})
        value
      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

10 entries across 10 versions & 1 rubygems

Version Path
flipper-0.7.5 lib/flipper/gates/boolean.rb
flipper-0.7.4 lib/flipper/gates/boolean.rb
flipper-0.7.3 lib/flipper/gates/boolean.rb
flipper-0.7.2 lib/flipper/gates/boolean.rb
flipper-0.7.1 lib/flipper/gates/boolean.rb
flipper-0.7.0 lib/flipper/gates/boolean.rb
flipper-0.7.0.beta6 lib/flipper/gates/boolean.rb
flipper-0.7.0.beta5 lib/flipper/gates/boolean.rb
flipper-0.7.0.beta4 lib/flipper/gates/boolean.rb
flipper-0.7.0.beta3 lib/flipper/gates/boolean.rb