Module: CConfig::HashUtils::Extensions

Defined in:
lib/cconfig/hash_utils.rb

Overview

Extensions contains the methods to be provided for each hash object produced by this gem.

Instance Method Summary collapse

Instance Method Details

#enabled?(feature) ⇒ Boolean

Returns true if the given feature is enabled, false otherwise. This also works in embedded configuration values. For example: enabled?(“a.b”) will return true for:

a:
  b:
    enabled: true

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
# File 'lib/cconfig/hash_utils.rb', line 33

def enabled?(feature)
  objs = feature.split(".")
  if objs.length == 2
    return false if !self[objs[0]][objs[1]] || self[objs[0]][objs[1]].empty?
    self[objs[0]][objs[1]]["enabled"].eql?(true)
  else
    return false if !self[feature] || self[feature].empty?
    self[feature]["enabled"].eql?(true)
  end
end