Class ArkanisDevelopment::SimpleLocalization::FeatureManager
In: lib/feature_manager.rb
Parent: Object

A singleton to manage which features should be loaded at what time.

Methods

Included Modules

Singleton

Public Class methods

[Source]

    # File lib/feature_manager.rb, line 10
10:       def initialize
11:         @all_features = read_available_features
12:         @plugin_init_features = []
13:         @frozen_plugin_init_features = nil
14:         @localization_init_features = []
15:         @disabled_features = []
16:       end

Public Instance methods

Returns all available features.

[Source]

    # File lib/feature_manager.rb, line 37
37:       def all_features
38:         @all_features
39:       end

Returns a list of all features marked for preload or loading.

[Source]

    # File lib/feature_manager.rb, line 58
58:       def all_loaded_features
59:         plugin_init_features + localization_init_features
60:       end

Disable the specified features. This removes the these features from the list of available features and from the list of features to preload.

[Source]

    # File lib/feature_manager.rb, line 26
26:       def disable(*features)
27:         @disabled_features.concat features.flatten
28:       end

Returns the list of disabled features.

[Source]

    # File lib/feature_manager.rb, line 63
63:       def disabled_features
64:         @disabled_features
65:       end

Freezes the list of features loaded at plugin initialization. After this call no more features can be marked for preload.

[Source]

    # File lib/feature_manager.rb, line 69
69:       def freeze_plugin_init_features!
70:         @frozen_plugin_init_features = plugin_init_features
71:       end

Mark the specified features for usual loading when initializing the localization.

[Source]

    # File lib/feature_manager.rb, line 32
32:       def load(*features)
33:         @localization_init_features.concat features.flatten
34:       end

Returns the features that can be loaded .

[Source]

    # File lib/feature_manager.rb, line 48
48:       def localization_init_features
49:         @all_features & (@localization_init_features - @plugin_init_features - @disabled_features)
50:       end

Returns the features that are requested to be loaded during plugin initialization.

[Source]

    # File lib/feature_manager.rb, line 43
43:       def plugin_init_features
44:         @frozen_plugin_init_features || (@all_features & (@plugin_init_features - @disabled_features))
45:       end

Mark the specified features for preload, meaning it‘s necessary to load them during plugin initialization.

[Source]

    # File lib/feature_manager.rb, line 20
20:       def preload(*features)
21:         @plugin_init_features.concat features.flatten
22:       end

Returns a list of preloaded features the user doesn‘t want to be loaded.

[Source]

    # File lib/feature_manager.rb, line 53
53:       def unwanted_features
54:         plugin_init_features - (@all_features & @localization_init_features)
55:       end

[Validate]