Class: Feature
- Inherits:
-
Object
- Object
- Feature
- Defined in:
- lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb
Overview
Feature model for App Configuration service
Instance Attribute Summary collapse
-
#disabled_value ⇒ Object
readonly
Returns the value of attribute disabled_value.
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#enabled_value ⇒ Object
readonly
Returns the value of attribute enabled_value.
-
#experiment ⇒ Object
readonly
Returns the value of attribute experiment.
-
#feature_id ⇒ Object
readonly
Returns the value of attribute feature_id.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rollout_configuration ⇒ Object
readonly
Returns the value of attribute rollout_configuration.
-
#rollout_percentage ⇒ Object
readonly
Returns the value of attribute rollout_percentage.
-
#rollout_type ⇒ Object
readonly
Returns the value of attribute rollout_type.
-
#segment_rules ⇒ Object
readonly
Returns the value of attribute segment_rules.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#get_current_value(entity_id, entity_attributes = {}) ⇒ Hash?
Evaluates and returns feature value for entity.
-
#get_feature_data_format ⇒ String?
Feature data format (TEXT/JSON/YAML).
-
#get_feature_data_type ⇒ String
Feature data type (BOOLEAN/STRING/NUMERIC).
-
#get_feature_id ⇒ String
Feature ID.
-
#get_feature_name ⇒ String
Feature name.
-
#initialize(feature) ⇒ Feature
constructor
A new instance of Feature.
-
#is_enabled? ⇒ Boolean
Feature enabled state.
Constructor Details
#initialize(feature) ⇒ Feature
Returns a new instance of Feature.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 27 def initialize(feature) @name = feature[:name] @feature_id = feature[:feature_id] @type = feature[:type] @format = feature[:format] @disabled_value = feature[:disabled_value] @enabled_value = feature[:enabled_value] @enabled = feature[:enabled] @rollout_type = feature.key?(:rollout_type) ? feature[:rollout_type] : Constants::MANUAL if feature[:rollout_configuration] @rollout_configuration = feature[:rollout_configuration] else @rollout_percentage = feature.key?(:rollout_percentage) ? feature[:rollout_percentage] : 100 end @segment_rules = feature[:segment_rules] @experiment = feature[:experiment] end |
Instance Attribute Details
#disabled_value ⇒ Object (readonly)
Returns the value of attribute disabled_value.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def disabled_value @disabled_value end |
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def enabled @enabled end |
#enabled_value ⇒ Object (readonly)
Returns the value of attribute enabled_value.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def enabled_value @enabled_value end |
#experiment ⇒ Object (readonly)
Returns the value of attribute experiment.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def experiment @experiment end |
#feature_id ⇒ Object (readonly)
Returns the value of attribute feature_id.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def feature_id @feature_id end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def format @format end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def name @name end |
#rollout_configuration ⇒ Object (readonly)
Returns the value of attribute rollout_configuration.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def rollout_configuration @rollout_configuration end |
#rollout_percentage ⇒ Object (readonly)
Returns the value of attribute rollout_percentage.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def rollout_percentage @rollout_percentage end |
#rollout_type ⇒ Object (readonly)
Returns the value of attribute rollout_type.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def rollout_type @rollout_type end |
#segment_rules ⇒ Object (readonly)
Returns the value of attribute segment_rules.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def segment_rules @segment_rules end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
22 23 24 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 22 def type @type end |
Instance Method Details
#get_current_value(entity_id, entity_attributes = {}) ⇒ Hash?
Evaluates and returns feature value for entity. Returns a hash containing evaluated value, enabled status & detailed reason.
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 110 def get_current_value(entity_id, entity_attributes = {}) if entity_id.nil? || entity_id.to_s.strip.empty? logger = Logger.instance logger.error("Feature flag evaluation: #{Constants::INVALID_ENTITY_ID} get_current_value") return nil end require_relative "../configuration_handler" configuration_handler_instance = ConfigurationHandler.instance configuration_handler_instance.feature_evaluation(self, entity_id, entity_attributes) end |
#get_feature_data_format ⇒ String?
Returns Feature data format (TEXT/JSON/YAML).
63 64 65 66 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 63 def get_feature_data_format @format = "TEXT" if @format.nil? && @type == "STRING" @format end |
#get_feature_data_type ⇒ String
Returns Feature data type (BOOLEAN/STRING/NUMERIC).
58 59 60 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 58 def get_feature_data_type @type || "" end |
#get_feature_id ⇒ String
Returns Feature ID.
53 54 55 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 53 def get_feature_id @feature_id || "" end |
#get_feature_name ⇒ String
Returns Feature name.
48 49 50 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 48 def get_feature_name @name || "" end |
#is_enabled? ⇒ Boolean
Returns Feature enabled state.
69 70 71 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/feature.rb', line 69 def is_enabled? @enabled end |