class Flop::Feature

Attributes

name[RW]
repo[RW]

Public Class Methods

new(name, repo = Flop.repo) click to toggle source
# File lib/flop/feature.rb, line 5
def initialize(name, repo = Flop.repo)
  self.name = name.to_sym
  self.repo = repo
end

Public Instance Methods

activate() click to toggle source
# File lib/flop/feature.rb, line 23
def activate
  set true
end
active?() click to toggle source
# File lib/flop/feature.rb, line 10
def active?
  repo.get(name)
end
deactivate() click to toggle source
# File lib/flop/feature.rb, line 27
def deactivate
  set false
end
inactive?() click to toggle source
# File lib/flop/feature.rb, line 14
def inactive?
  !active?
end
set(value) click to toggle source
# File lib/flop/feature.rb, line 18
def set(value)
  repo.set(name, value)
  value
end
toggle() click to toggle source
# File lib/flop/feature.rb, line 31
def toggle
  set !active?
end
with() { |block| ... } click to toggle source
# File lib/flop/feature.rb, line 35
def with(&block)
  yield block if active?
end
without() { |block| ... } click to toggle source
# File lib/flop/feature.rb, line 39
def without(&block)
  yield block if inactive?
end