Class: Microkit::FeatureItem
Instance Attribute Summary
Attributes inherited from Item
Instance Method Summary collapse
- #get_value(user = nil) ⇒ Object
-
#initialize(value, name) ⇒ FeatureItem
constructor
A new instance of FeatureItem.
Methods inherited from Item
#get_item_value, #update, #value
Constructor Details
#initialize(value, name) ⇒ FeatureItem
Returns a new instance of FeatureItem.
3 4 5 |
# File 'lib/microkit/feature_item.rb', line 3 def initialize(value, name) super(value, name) end |
Instance Method Details
#get_value(user = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/microkit/feature_item.rb', line 7 def get_value (user = nil) if !user or !@item["targeting_groups"] or @item["targeting_groups"].length == 0 then return self.value else features = {} features[@name] = {"value" => @item["value"], "type" => @item["type"], "targeting_groups" => @item["targeting_groups"]} res = HttpClient.instance.post("get_user_data", "get_feature_by_user", {"user" => user, "features" => features}) res = JSON.parse(res) return self.get_item_value(res["features"][@name]) end end |