module Flippant

Constants

Error
VERSION

Attributes

adapter[W]
registry[W]
serializer[W]

Public Instance Methods

adapter() click to toggle source

Configuration

# File lib/flippant.rb, line 80
def adapter
  @adapter ||= Flippant::Adapter::Memory.new
end
add(feature) click to toggle source

Guarded Delegation

# File lib/flippant.rb, line 36
def add(feature)
  adapter.add(normalize(feature))
end
clear(selection = nil) click to toggle source
# File lib/flippant.rb, line 96
def clear(selection = nil)
  case selection
  when :features then adapter.clear
  when :groups then registry.clear
  else adapter.clear && registry.clear
  end
end
configure() { |self| ... } click to toggle source
# File lib/flippant.rb, line 92
def configure
  yield self
end
disable(feature, group, values = []) click to toggle source
# File lib/flippant.rb, line 60
def disable(feature, group, values = [])
  adapter.disable(normalize(feature), group, values)
end
dump(path) click to toggle source
# File lib/flippant.rb, line 40
def dump(path)
  File.open(path, "w+") do |file|
    file << serializer.dump(breakdown)
  end
end
enable(feature, group, values = []) click to toggle source
# File lib/flippant.rb, line 50
def enable(feature, group, values = [])
  raise Flippant::Error, "Unknown group: #{group}" unless registered?(group)

  adapter.enable(normalize(feature), group, values)
end
enabled?(feature, actor) click to toggle source
# File lib/flippant.rb, line 56
def enabled?(feature, actor)
  adapter.enabled?(normalize(feature), actor)
end
exists?(features, group = nil) click to toggle source
# File lib/flippant.rb, line 46
def exists?(features, group = nil)
  adapter.exists?(normalize(features), group)
end
load(path) click to toggle source
# File lib/flippant.rb, line 64
def load(path)
  File.open(path, "r") do |file|
    adapter.load(serializer.load(file.read))
  end
end
registry() click to toggle source
# File lib/flippant.rb, line 84
def registry
  @registry ||= Flippant::Registry.new
end
remove(feature) click to toggle source
# File lib/flippant.rb, line 74
def remove(feature)
  adapter.remove(normalize(feature))
end
rename(old_name, new_name) click to toggle source
# File lib/flippant.rb, line 70
def rename(old_name, new_name)
  adapter.rename(normalize(old_name), normalize(new_name))
end
serializer() click to toggle source
# File lib/flippant.rb, line 88
def serializer
  @serializer ||= JSON
end

Private Instance Methods

normalize(feature) click to toggle source
# File lib/flippant.rb, line 106
def normalize(feature)
  feature.to_s.downcase.strip
end