Class: Flipper::Gates::Group

Inherits:
Flipper::Gate show all
Defined in:
lib/flipper/gates/group.rb

Instance Method Summary collapse

Methods inherited from Flipper::Gate

#initialize, #inspect

Constructor Details

This class inherits a constructor from Flipper::Gate

Instance Method Details

#data_typeObject



14
15
16
# File 'lib/flipper/gates/group.rb', line 14

def data_type
  :set
end

#enabled?(value) ⇒ Boolean

Returns:



18
19
20
# File 'lib/flipper/gates/group.rb', line 18

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

#keyObject

Internal: Name converted to value safe for adapter.



10
11
12
# File 'lib/flipper/gates/group.rb', line 10

def key
  :groups
end

#nameObject

Internal: The name of the gate. Used for instrumentation, etc.



5
6
7
# File 'lib/flipper/gates/group.rb', line 5

def name
  :group
end

#open?(context) ⇒ Boolean

Internal: Checks if the gate is open for a thing.

Returns true if gate open for thing, false if not.

Returns:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/flipper/gates/group.rb', line 25

def open?(context)
  value = context.values[key]
  if context.thing.nil?
    false
  else
    value.any? do |name|
      group = Flipper.group(name)
      group.match?(context.thing, context)
    end
  end
end

#protects?(thing) ⇒ Boolean

Returns:



41
42
43
# File 'lib/flipper/gates/group.rb', line 41

def protects?(thing)
  thing.is_a?(Types::Group) || thing.is_a?(Symbol)
end

#wrap(thing) ⇒ Object



37
38
39
# File 'lib/flipper/gates/group.rb', line 37

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