Sha256: cdb9b30723823f1abde7af73bd02664766de16ca368e83871323e0d3f823a09d
Contents?: true
Size: 1.24 KB
Versions: 5
Compression:
Stored size: 1.24 KB
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 description(value) if enabled?(value) actor_ids = value.to_a.sort.map { |id| id.inspect } "actors (#{actor_ids.join(', ')})" else 'disabled' end end def enabled?(value) !value.nil? && !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?(thing, value) instrument(:open?, thing) { |payload| if thing.nil? false else if protects?(thing) actor = wrap(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
5 entries across 5 versions & 1 rubygems