Class: FeatureFlagger::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_flagger/feature.rb

Instance Method Summary collapse

Constructor Details

#initialize(key, resource_name = nil) ⇒ Feature

Returns a new instance of Feature.


4
5
6
7
8
# File 'lib/feature_flagger/feature.rb', line 4

def initialize(key, resource_name = nil)
  @key = resource_name.nil? ? key : key.clone.insert(0, resource_name)
  @key = Array(@key).collect(&:to_s)
  @doc = FeatureFlagger.config[:info]
end

Instance Method Details

#descriptionObject


16
17
18
19
# File 'lib/feature_flagger/feature.rb', line 16

def description
  fetch!
  @data['description']
end

#fetch!Object


10
11
12
13
14
# File 'lib/feature_flagger/feature.rb', line 10

def fetch!
  @data ||= find_value(@doc, *@key)
  raise FeatureFlagger::KeyNotFoundError.new(@key) if @data.nil?
  @data
end