Class: Feature::Repository::YamlRepository
- Inherits:
-
Object
- Object
- Feature::Repository::YamlRepository
- 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
-
#active_features ⇒ Array<Symbol>
Returns list of active features.
-
#check_valid_feature_data(features) ⇒ Object
Checks for valid values in given feature hash.
-
#initialize(yaml_file_name, environment = '') ⇒ YamlRepository
constructor
Constructor.
Constructor Details
#initialize(yaml_file_name, environment = '') ⇒ YamlRepository
Constructor
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_features ⇒ Array<Symbol>
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 |
#check_valid_feature_data(features) ⇒ Object
Checks for valid values in given feature hash
84 85 86 87 88 89 90 |
# File 'lib/feature/repository/yaml_repository.rb', line 84 def check_valid_feature_data(features) features.values.each do |value| unless [true, false].include?(value) fail ArgumentError, "#{value} is not allowed value in config, use true/false" end end end |