Module: Flagon

Defined in:
lib/flagon.rb,
lib/flagon/inspector.rb,
lib/flagon/loader/env_loader.rb,
lib/flagon/loader/file_loader.rb,
lib/flagon/loader/hash_loader.rb

Defined Under Namespace

Modules: Loader Classes: Inspector, NotInitialized

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.inspectorObject (readonly)

Returns the value of attribute inspector.



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

def inspector
  @inspector
end

Class Method Details

.enabled?(flag_name) ⇒ Boolean

Convenience methods to allow calling Flagon.enabled? directly

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/flagon.rb', line 30

def enabled?(flag_name)
  check_initialized
  @inspector.enabled?(flag_name)
end

.ensure_flags_exist(*flags) ⇒ Object



40
41
42
43
# File 'lib/flagon.rb', line 40

def ensure_flags_exist(*flags)
  check_initialized
  @inspector.ensure_flags_exist(*flags)
end

.env_loaderObject

Pre-defined loaders



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

def env_loader
  Loader::EnvLoader.new
end

.file_loader(path) ⇒ Object



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

def file_loader(path)
  Loader::FileLoader.new(path)
end

.hash_loader(init_hash) ⇒ Object



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

def hash_loader(init_hash)
  Loader::HashLoader.new(init_hash)
end

.init(loader = env_loader) ⇒ Object

Init method takes one of the loaders listed below or a custom loader that responds to the same interface



12
13
14
# File 'lib/flagon.rb', line 12

def init(loader = env_loader)
  @inspector = Inspector.new(loader)
end

.when_enabled(flag_name, &block) ⇒ Object



35
36
37
38
# File 'lib/flagon.rb', line 35

def when_enabled(flag_name, &block)
  check_initialized
  @inspector.when_enabled(flag_name, &block)
end