Class: Growthbook::Feature
- Inherits:
-
Object
- Object
- Growthbook::Feature
- Defined in:
- lib/growthbook/feature.rb
Overview
The feature with a generic value type.
Instance Attribute Summary collapse
- #default_value ⇒ Any? readonly
- #rules ⇒ Array<Growthbook::FeatureRule> readonly
Instance Method Summary collapse
-
#initialize(feature) ⇒ Feature
constructor
A new instance of Feature.
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(feature) ⇒ Feature
Returns a new instance of Feature.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/growthbook/feature.rb', line 12 def initialize(feature) @default_value = get_option(feature, :defaultValue) rules = get_option(feature, :rules) @rules = [] rules&.each do |rule| @rules << Growthbook::FeatureRule.new(rule) end end |
Instance Attribute Details
#default_value ⇒ Any? (readonly)
7 8 9 |
# File 'lib/growthbook/feature.rb', line 7 def default_value @default_value end |
#rules ⇒ Array<Growthbook::FeatureRule> (readonly)
10 11 12 |
# File 'lib/growthbook/feature.rb', line 10 def rules @rules end |
Instance Method Details
#to_json(*_args) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/growthbook/feature.rb', line 23 def to_json(*_args) res = {} res['defaultValue'] = @default_value unless @default_value.nil? res['rules'] = [] @rules.each do |rule| res['rules'] << rule.to_json end res end |