Sha256: 49dc2a3a727d78a70d77d3f1a5ad112d959731f2d4beb939db7e8ed9e391ef92

Contents?: true

Size: 1.46 KB

Versions: 55

Compression:

Stored size: 1.46 KB

Contents

module Flipper
  class Gate
    # Public
    def initialize(options = {})
    end

    # Public: The name of the gate. Implemented in subclass.
    def name
      raise 'Not implemented'
    end

    # Private: Name converted to value safe for adapter. Implemented in subclass.
    def key
      raise 'Not implemented'
    end

    def data_type
      raise 'Not implemented'
    end

    def enabled?(_value)
      raise 'Not implemented'
    end

    # Internal: Check if a gate is open for a thing. Implemented in subclass.
    #
    # Returns true if gate open for thing, false if not.
    def open?(_thing, _value, _options = {})
      false
    end

    # Internal: Check if a gate is protects a thing. Implemented in subclass.
    #
    # Returns true if gate protects thing, false if not.
    def protects?(_thing)
      false
    end

    # Internal: Allows gate to wrap thing using one of the supported flipper
    # types so adapters always get something that responds to value.
    def wrap(thing)
      thing
    end

    # Public: Pretty string version for debugging.
    def inspect
      attributes = [
        "name=#{name.inspect}",
        "key=#{key.inspect}",
        "data_type=#{data_type.inspect}",
      ]
      "#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>"
    end
  end
end

require 'flipper/gates/actor'
require 'flipper/gates/boolean'
require 'flipper/gates/group'
require 'flipper/gates/percentage_of_actors'
require 'flipper/gates/percentage_of_time'

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
flipper-0.27.1 lib/flipper/gate.rb
flipper-0.27.0 lib/flipper/gate.rb
flipper-0.26.2 lib/flipper/gate.rb
flipper-0.26.1 lib/flipper/gate.rb
flipper-0.26.0 lib/flipper/gate.rb
flipper-0.26.0.rc2 lib/flipper/gate.rb
flipper-0.26.0.rc1 lib/flipper/gate.rb
flipper-0.25.4 lib/flipper/gate.rb
flipper-0.25.3 lib/flipper/gate.rb
flipper-0.25.2 lib/flipper/gate.rb
flipper-0.25.1 lib/flipper/gate.rb
flipper-0.25.0 lib/flipper/gate.rb
flipper-0.24.1 lib/flipper/gate.rb
flipper-0.24.0 lib/flipper/gate.rb
flipper-0.23.1 lib/flipper/gate.rb
flipper-0.23.0 lib/flipper/gate.rb
flipper-0.22.2 lib/flipper/gate.rb
flipper-0.22.1 lib/flipper/gate.rb
flipper-0.22.0 lib/flipper/gate.rb
flipper-0.21.0 lib/flipper/gate.rb