Class: FeatureModel
- Inherits:
-
Object
- Object
- FeatureModel
- Defined in:
- lib/wingify/models/campaign/feature_model.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#impact_campaign ⇒ Object
readonly
Returns the value of attribute impact_campaign.
-
#is_gateway_service_required ⇒ Object
readonly
Returns the value of attribute is_gateway_service_required.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#rules_linked_campaign ⇒ Object
readonly
Returns the value of attribute rules_linked_campaign.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #get_id ⇒ Object
- #get_impact_campaign ⇒ Object
- #get_is_gateway_service_required ⇒ Object
- #get_key ⇒ Object
- #get_metrics ⇒ Object
- #get_name ⇒ Object
- #get_rules ⇒ Object
- #get_rules_linked_campaign ⇒ Object
- #get_type ⇒ Object
-
#initialize ⇒ FeatureModel
constructor
A new instance of FeatureModel.
-
#model_from_dictionary(feature) ⇒ Object
Creates a model instance from a hash (dictionary).
-
#process_metrics(metric_list) ⇒ Object
Process metrics list.
-
#process_rules(rule_list) ⇒ Object
Process rules list.
-
#set_is_gateway_service_required(is_gateway_service_required) ⇒ Object
Setter method for is_gateway_service_required.
-
#set_rules_linked_campaign(rules_linked_campaign) ⇒ Object
Setter method for rules_linked_campaign.
Constructor Details
#initialize ⇒ FeatureModel
Returns a new instance of FeatureModel.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 23 def initialize @id = nil @key = '' @name = '' @type = '' @rules = [] @impact_campaign = nil @rules_linked_campaign = [] @metrics = [] @is_gateway_service_required = false end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def id @id end |
#impact_campaign ⇒ Object (readonly)
Returns the value of attribute impact_campaign.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def impact_campaign @impact_campaign end |
#is_gateway_service_required ⇒ Object (readonly)
Returns the value of attribute is_gateway_service_required.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def is_gateway_service_required @is_gateway_service_required end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def key @key end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def metrics @metrics end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def name @name end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def rules @rules end |
#rules_linked_campaign ⇒ Object (readonly)
Returns the value of attribute rules_linked_campaign.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def rules_linked_campaign @rules_linked_campaign end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 21 def type @type end |
Instance Method Details
#get_id ⇒ Object
64 65 66 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 64 def get_id @id end |
#get_impact_campaign ⇒ Object
84 85 86 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 84 def get_impact_campaign @impact_campaign end |
#get_is_gateway_service_required ⇒ Object
96 97 98 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 96 def get_is_gateway_service_required @is_gateway_service_required end |
#get_key ⇒ Object
68 69 70 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 68 def get_key @key end |
#get_metrics ⇒ Object
92 93 94 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 92 def get_metrics @metrics end |
#get_name ⇒ Object
72 73 74 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 72 def get_name @name end |
#get_rules ⇒ Object
80 81 82 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 80 def get_rules @rules end |
#get_rules_linked_campaign ⇒ Object
88 89 90 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 88 def get_rules_linked_campaign @rules_linked_campaign end |
#get_type ⇒ Object
76 77 78 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 76 def get_type @type end |
#model_from_dictionary(feature) ⇒ Object
Creates a model instance from a hash (dictionary)
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 36 def model_from_dictionary(feature) @id = feature["id"] @key = feature["key"] @name = feature["name"] @type = feature["type"] @is_gateway_service_required = feature["is_gateway_service_required"] if feature.key?("is_gateway_service_required") if feature["impactCampaign"] @impact_campaign = ImpactCampaignModel.new.model_from_dictionary(feature["impactCampaign"]) end @metrics = process_metrics(feature["metrics"]) @rules = process_rules(feature["rules"]) @rules_linked_campaign = feature["rules_linked_campaign"].is_a?(Array) ? feature["rules_linked_campaign"] : [] self end |
#process_metrics(metric_list) ⇒ Object
Process metrics list
107 108 109 110 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 107 def process_metrics(metric_list) return [] unless metric_list.is_a?(Array) metric_list.map { |metric| MetricModel.new.model_from_dictionary(metric) } end |
#process_rules(rule_list) ⇒ Object
Process rules list
101 102 103 104 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 101 def process_rules(rule_list) return [] unless rule_list.is_a?(Array) rule_list.map { |rule| RuleModel.new.model_from_dictionary(rule) } end |
#set_is_gateway_service_required(is_gateway_service_required) ⇒ Object
Setter method for is_gateway_service_required
60 61 62 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 60 def set_is_gateway_service_required(is_gateway_service_required) @is_gateway_service_required = is_gateway_service_required end |
#set_rules_linked_campaign(rules_linked_campaign) ⇒ Object
Setter method for rules_linked_campaign
55 56 57 |
# File 'lib/wingify/models/campaign/feature_model.rb', line 55 def set_rules_linked_campaign(rules_linked_campaign) @rules_linked_campaign = rules_linked_campaign end |