Class: Flagon::Inspector
- Inherits:
-
Object
- Object
- Flagon::Inspector
- Defined in:
- lib/flagon/inspector.rb
Defined Under Namespace
Classes: FlagMissing
Instance Attribute Summary collapse
-
#loader ⇒ Object
readonly
Returns the value of attribute loader.
Instance Method Summary collapse
- #enabled?(flag_name) ⇒ Boolean
- #ensure_flags_exist(*flags) ⇒ Object
-
#initialize(loader) ⇒ Inspector
constructor
A new instance of Inspector.
- #when_enabled(flag_name) ⇒ Object
Constructor Details
#initialize(loader) ⇒ Inspector
Returns a new instance of Inspector.
5 6 7 |
# File 'lib/flagon/inspector.rb', line 5 def initialize(loader) @loader = loader end |
Instance Attribute Details
#loader ⇒ Object (readonly)
Returns the value of attribute loader.
3 4 5 |
# File 'lib/flagon/inspector.rb', line 3 def loader @loader end |
Instance Method Details
#enabled?(flag_name) ⇒ Boolean
9 10 11 12 |
# File 'lib/flagon/inspector.rb', line 9 def enabled?(flag_name) return false unless exists?(flag_name) get_flag(flag_name) end |
#ensure_flags_exist(*flags) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/flagon/inspector.rb', line 20 def ensure_flags_exist(*flags) missing_flags = flags.select do |flag_name| !exists?(flag_name) end raise FlagMissing, "The following flags are missing: #{missing_flags.join(', ')}" unless missing_flags.empty? end |
#when_enabled(flag_name) ⇒ Object
14 15 16 17 18 |
# File 'lib/flagon/inspector.rb', line 14 def when_enabled(flag_name) if enabled?(flag_name) yield end end |