Class: SmoothChange::Adapters::Yaml

Inherits:
Object
  • Object
show all
Defined in:
lib/smooth_change/adapters/yaml.rb

Overview

Load features from a YAML file

Instance Method Summary collapse

Constructor Details

#initialize(file:) ⇒ Yaml

Returns a new instance of Yaml.



7
8
9
10
11
12
13
14
# File 'lib/smooth_change/adapters/yaml.rb', line 7

def initialize(file:)
  @file_content = if file.respond_to?(:read)
                    file.read
                  else
                    File.read(file)
                  end
  parse_file
end

Instance Method Details

#featuresObject



16
17
18
# File 'lib/smooth_change/adapters/yaml.rb', line 16

def features
  @features ||= {}.with_indifferent_access
end

#get(feature_name) ⇒ Feature

Parameters:

  • feature_name (string)

Returns:



22
23
24
# File 'lib/smooth_change/adapters/yaml.rb', line 22

def get(feature_name)
  @features[feature_name]
end