Class: FeatureMap::CodeFeatures::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_map/code_features/plugin.rb

Overview

Plugins allow a client to add validation on custom keys in the feature YML. For now, only a single plugin is allowed to manage validation on a top-level key. In the future we can think of allowing plugins to be gracefully merged with each other.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature) ⇒ Plugin

Returns a new instance of Plugin.



7
8
9
# File 'lib/feature_map/code_features/plugin.rb', line 7

def initialize(feature)
  @feature = feature
end

Class Method Details

.all_pluginsObject



15
16
17
18
# File 'lib/feature_map/code_features/plugin.rb', line 15

def self.all_plugins
  @all_plugins ||= []
  @all_plugins
end

.bust_caches!Object



48
49
50
# File 'lib/feature_map/code_features/plugin.rb', line 48

def self.bust_caches!
  all_plugins.each(&:clear_feature_registry!)
end

.clear_feature_registry!Object



52
53
54
# File 'lib/feature_map/code_features/plugin.rb', line 52

def self.clear_feature_registry!
  @registry = nil
end

.for(feature) ⇒ Object



24
25
26
# File 'lib/feature_map/code_features/plugin.rb', line 24

def self.for(feature)
  register_feature(feature)
end

.inherited(base) ⇒ Object

rubocop:disable Lint/MissingSuper



11
12
13
# File 'lib/feature_map/code_features/plugin.rb', line 11

def self.inherited(base) # rubocop:disable Lint/MissingSuper
  all_plugins << base
end

.missing_key_error_message(feature, key) ⇒ Object



28
29
30
# File 'lib/feature_map/code_features/plugin.rb', line 28

def self.missing_key_error_message(feature, key)
  "#{feature.name} is missing required key `#{key}`"
end

.validation_errors(features) ⇒ Object



20
21
22
# File 'lib/feature_map/code_features/plugin.rb', line 20

def self.validation_errors(features)
  []
end