Class: Property
- Inherits:
-
Object
- Object
- Property
- Defined in:
- lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb
Overview
Defines the model of a Property defined in App Configuration service.
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#property_id ⇒ Object
readonly
Returns the value of attribute property_id.
-
#segment_rules ⇒ Object
readonly
Returns the value of attribute segment_rules.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#get_current_value(entity_id, entity_attributes = {}) ⇒ Hash?
Get the evaluated value of the property.
-
#get_property_data_format ⇒ String?
Get the Property data format applicable only for STRING datatype property.
-
#get_property_data_type ⇒ String
Get the Property data type.
-
#get_property_id ⇒ String
Get the Property id.
-
#get_property_name ⇒ String
Get the Property name.
-
#initialize(property) ⇒ Property
constructor
Initialize a new Property instance.
Constructor Details
#initialize(property) ⇒ Property
Initialize a new Property instance
28 29 30 31 32 33 34 35 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 28 def initialize(property) @name = property[:name] @property_id = property[:property_id] @type = property[:type] @format = property[:format] # will be nil for boolean & numeric datatypes @value = property[:value] @segment_rules = property[:segment_rules] end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
23 24 25 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 23 def format @format end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 23 def name @name end |
#property_id ⇒ Object (readonly)
Returns the value of attribute property_id.
23 24 25 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 23 def property_id @property_id end |
#segment_rules ⇒ Object (readonly)
Returns the value of attribute segment_rules.
23 24 25 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 23 def segment_rules @segment_rules end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 23 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
23 24 25 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 23 def value @value end |
Instance Method Details
#get_current_value(entity_id, entity_attributes = {}) ⇒ Hash?
Get the evaluated value of the property.
This will be a string identifier related to the Entity against which the property is evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App Configuration, it must provide a unique entity ID.
This is an optional parameter if the property is not configured with any targeting definition. If the targeting is configured, then entity_attributes should be provided for the rule evaluation. An attribute is a parameter that is used to define a segment. The SDK uses the attribute values to determine if the specified entity satisfies the targeting rules, and returns the appropriate property value.
The evaluated value will be either the default property value or its overridden value based on the evaluation. The data type of returned value matches that of property. Returns nil if entity_id is invalid.
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 96 def get_current_value(entity_id, entity_attributes = {}) if entity_id.nil? || entity_id.to_s.strip.empty? logger = Logger.instance logger.error("Property evaluation: #{Constants::INVALID_ENTITY_ID} get_current_value") return nil end require_relative "../configuration_handler" configuration_handler_instance = ConfigurationHandler.instance configuration_handler_instance.property_evaluation(self, entity_id, entity_attributes) end |
#get_property_data_format ⇒ String?
Get the Property data format applicable only for STRING datatype property.
63 64 65 66 67 68 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 63 def get_property_data_format # Format will be `nil` for Boolean & Numeric properties # If the Format is nil for a String type, we default it to TEXT @format = "TEXT" if @format.nil? && @type == "STRING" @format end |
#get_property_data_type ⇒ String
Get the Property data type
54 55 56 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 54 def get_property_data_type @type || "" end |
#get_property_id ⇒ String
Get the Property id
47 48 49 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 47 def get_property_id @property_id || "" end |
#get_property_name ⇒ String
Get the Property name
40 41 42 |
# File 'lib/ibm_appconfiguration_ruby_sdk/configurations/models/property.rb', line 40 def get_property_name @name || "" end |