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.



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

def initialize(name, adapter)
  @name = name
  @adapter = Adapter.wrap(adapter)
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



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

def adapter
  @adapter
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

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



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

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

#disabled?(actor = nil) ⇒ Boolean

Returns:

  • (Boolean)


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

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

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



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

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

#enabled?(actor = nil) ⇒ Boolean

Returns:

  • (Boolean)


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

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