Class: Feature::Repository::YamlRepository

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

Overview

YamlRepository for active and inactive features The yaml config file should look like this:

features:
    an_active_feature: true
    an_inactive_feature: false

Example usage:

repository = YamlRepository.new('/path/to/yaml/file')
# use repository with Feature

A yaml config also can have this format:

features:
  development:
    a_feature: true
  production:
    a_feature: false

This way you have to use:

repository = YamlRepository.new('/path/to/yaml/file', '_your_environment_')
# use repository with Feature

Instance Method Summary collapse

Constructor Details

#initialize(yaml_file_name, environment = '') ⇒ YamlRepository

Constructor

Parameters:

  • the yaml config filename

  • (defaults to: '')

    optional environment to use from config



34
35
36
37
# File 'lib/feature/repository/yaml_repository.rb', line 34

def initialize(yaml_file_name, environment = '')
  @yaml_file_name = yaml_file_name
  @environment = environment
end

Instance Method Details

#active_featuresArray<Symbol>

Returns list of active features

Returns:

  • list of active features



43
44
45
46
# File 'lib/feature/repository/yaml_repository.rb', line 43

def active_features
  data = read_file(@yaml_file_name)
  get_active_features(data, @environment)
end