Class: Flipper::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/flipper/feature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, adapter) ⇒ Feature

Returns a new instance of Feature.



11
12
13
14
# File 'lib/flipper/feature.rb', line 11

def initialize(name, adapter)
  @name = name
  @adapter = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



9
10
11
# File 'lib/flipper/feature.rb', line 9

def adapter
  @adapter
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/flipper/feature.rb', line 8

def name
  @name
end

Instance Method Details

#disable(thing = Types::Boolean.new) ⇒ Object



20
21
22
# File 'lib/flipper/feature.rb', line 20

def disable(thing = Types::Boolean.new)
  gate_for(thing).disable(thing)
end

#disabled?(actor = nil) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/flipper/feature.rb', line 28

def disabled?(actor = nil)
  !enabled?(actor)
end

#enable(thing = Types::Boolean.new) ⇒ Object



16
17
18
# File 'lib/flipper/feature.rb', line 16

def enable(thing = Types::Boolean.new)
  gate_for(thing).enable(thing)
end

#enabled?(actor = nil) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/flipper/feature.rb', line 24

def enabled?(actor = nil)
  !! catch(:short_circuit) { gates.detect { |gate| gate.open?(actor) } }
end