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, environment = '') ⇒ YamlRepository

Constructor

Parameters:

  • yaml_file_name (String)

    the yaml config filename

  • environment (String) (defaults to: '')

    optional environment to use from config



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

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:

  • (Array<Symbol>)

    list of active features



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

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