Module: FeatureFlags::FeatureBase
- Extended by:
- ActiveSupport::Concern
- Included in:
- Feature
- Defined in:
- lib/feature_flags/feature_base.rb
Constant Summary collapse
- @@features_hash =
{}
Class Method Summary collapse
-
.features ⇒ Object
returns features hash.
-
.get_pstore_value ⇒ Object
returns current value in pstore.
-
.set_hash ⇒ Object
updates hash for features.
Instance Method Summary collapse
Class Method Details
.features ⇒ Object
returns features hash
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/feature_flags/feature_base.rb', line 14 def self.features ##checking value in pstore if false then update to true and update features_hash pstore_value = get_pstore_value @@features_hash = {} unless (pstore_value.present? && !defined? Rails::Console) if(@@features_hash.present? && pstore_value.present?) @@features_hash else set_hash Feature.new.update_pstore_hash end @@features_hash end |
.get_pstore_value ⇒ Object
returns current value in pstore
30 31 32 33 |
# File 'lib/feature_flags/feature_base.rb', line 30 def self.get_pstore_value store = PStore.new('feature_flags') store.transaction {store[:updated]} end |
.set_hash ⇒ Object
updates hash for features
36 37 38 39 40 |
# File 'lib/feature_flags/feature_base.rb', line 36 def self.set_hash @@features_hash = {} Feature.all.map{|f| @@features_hash[f.name.to_s.intern] = f.status} @@features_hash.freeze end |
Instance Method Details
#update_hash ⇒ Object
42 43 44 45 |
# File 'lib/feature_flags/feature_base.rb', line 42 def update_hash FeatureFlags::FeatureBase.set_hash update_pstore_hash end |
#update_pstore_hash ⇒ Object
47 48 49 |
# File 'lib/feature_flags/feature_base.rb', line 47 def update_pstore_hash FeatureFlags.update_pstore_value(!defined? Rails::Console) end |