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

Instance Method Summary collapse

Constructor Details

#initialize(yaml_file_name) ⇒ YamlRepository

Constructor

Parameters:

  • yaml_file_name (String)

    the yaml config filename



22
23
24
# File 'lib/feature/repository/yaml_repository.rb', line 22

def initialize(yaml_file_name)
  @yaml_file_name = yaml_file_name
end

Instance Method Details

#active_featuresArray<Symbol>

Returns list of active features

Returns:

  • (Array<Symbol>)

    list of active features



30
31
32
33
34
# File 'lib/feature/repository/yaml_repository.rb', line 30

def active_features
  features_hash = read_and_parse_file_data
  features = features_hash.keys.select { |feature_key| features_hash[feature_key] }
  features.sort.map(&:to_sym)
end