Sha256: 6d27caf363049ae34aa541f3c5448594d49f5a1fe07c46639b4d2a2525045434

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 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 description(value)
        if enabled?(value)
          'Enabled'
        else
          'Disabled'
        end
      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 protects?(thing)
        thing.is_a?(Flipper::Types::Boolean)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flipper-0.7.0.beta2 lib/flipper/gates/boolean.rb
flipper-0.7.0.beta1 lib/flipper/gates/boolean.rb