Sha256: 5113e956789dae10b2b1d6d526721b962c2be03fef6246acd31977134343786d

Contents?: true

Size: 1012 Bytes

Versions: 54

Compression:

Stored size: 1012 Bytes

Contents

module Flipper
  module Gates
    class Actor < Gate
      # Internal: The name of the gate. Used for instrumentation, etc.
      def name
        :actor
      end

      # Internal: Name converted to value safe for adapter.
      def key
        :actors
      end

      def data_type
        :set
      end

      def enabled?(value)
        !value.empty?
      end

      # Internal: Checks if the gate is open for a thing.
      #
      # Returns true if gate open for thing, false if not.
      def open?(context)
        value = context.values[key]
        if context.thing.nil?
          false
        else
          if protects?(context.thing)
            actor = wrap(context.thing)
            enabled_actor_ids = value
            enabled_actor_ids.include?(actor.value)
          else
            false
          end
        end
      end

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

      def protects?(thing)
        Types::Actor.wrappable?(thing)
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
flipper-0.12.0 lib/flipper/gates/actor.rb
flipper-0.11.0 lib/flipper/gates/actor.rb
flipper-0.11.0.rc1 lib/flipper/gates/actor.rb
flipper-0.11.0.beta9 lib/flipper/gates/actor.rb
flipper-0.11.0.beta8 lib/flipper/gates/actor.rb
flipper-0.11.0.beta7 lib/flipper/gates/actor.rb
flipper-0.11.0.beta6 lib/flipper/gates/actor.rb
flipper-0.11.0.beta5 lib/flipper/gates/actor.rb
flipper-0.11.0.beta4 lib/flipper/gates/actor.rb
flipper-0.11.0.beta3 lib/flipper/gates/actor.rb
flipper-0.11.0.beta1 lib/flipper/gates/actor.rb
flipper-0.10.2 lib/flipper/gates/actor.rb
flipper-0.10.1 lib/flipper/gates/actor.rb
flipper-0.10.0 lib/flipper/gates/actor.rb