Module: Fino::Setting
- Includes:
- PrettyInspectable
- Included in:
- Fino::Settings::Boolean, Fino::Settings::Float, Fino::Settings::Integer, Fino::Settings::Select, Fino::Settings::String
- Defined in:
- lib/fino/setting.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#experiment ⇒ Object
readonly
Returns the value of attribute experiment.
-
#global_value ⇒ Object
readonly
Returns the value of attribute global_value.
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
Class Method Summary collapse
Instance Method Summary collapse
- #ab_tested? ⇒ Boolean
- #default ⇒ Object
- #description ⇒ Object
- #initialize(definition, global_value, overrides = {}, experiment = nil) ⇒ Object
- #key ⇒ Object
- #name ⇒ Object
- #overriden? ⇒ Boolean
- #section_definition ⇒ Object
- #section_name ⇒ Object
- #type ⇒ Object
- #type_class ⇒ Object
- #value(**context) ⇒ Object
Methods included from PrettyInspectable
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
28 29 30 |
# File 'lib/fino/setting.rb', line 28 def definition @definition end |
#experiment ⇒ Object (readonly)
Returns the value of attribute experiment.
28 29 30 |
# File 'lib/fino/setting.rb', line 28 def experiment @experiment end |
#global_value ⇒ Object (readonly)
Returns the value of attribute global_value.
28 29 30 |
# File 'lib/fino/setting.rb', line 28 def global_value @global_value end |
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
28 29 30 |
# File 'lib/fino/setting.rb', line 28 def overrides @overrides end |
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/fino/setting.rb', line 6 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#ab_tested? ⇒ Boolean
86 87 88 |
# File 'lib/fino/setting.rb', line 86 def ab_tested? !!experiment end |
#default ⇒ Object
74 75 76 |
# File 'lib/fino/setting.rb', line 74 def default definition.default end |
#description ⇒ Object
78 79 80 |
# File 'lib/fino/setting.rb', line 78 def description definition.description end |
#initialize(definition, global_value, overrides = {}, experiment = nil) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/fino/setting.rb', line 30 def initialize(definition, global_value, overrides = {}, experiment = nil) @definition = definition @global_value = global_value @overrides = overrides @experiment = experiment end |
#key ⇒ Object
54 55 56 |
# File 'lib/fino/setting.rb', line 54 def key definition.key end |
#name ⇒ Object
50 51 52 |
# File 'lib/fino/setting.rb', line 50 def name definition.setting_name end |
#overriden? ⇒ Boolean
82 83 84 |
# File 'lib/fino/setting.rb', line 82 def overriden? !overrides.empty? end |
#section_definition ⇒ Object
66 67 68 |
# File 'lib/fino/setting.rb', line 66 def section_definition definition.section_definition end |
#section_name ⇒ Object
70 71 72 |
# File 'lib/fino/setting.rb', line 70 def section_name definition.section_definition&.name end |
#type ⇒ Object
58 59 60 |
# File 'lib/fino/setting.rb', line 58 def type definition.type end |
#type_class ⇒ Object
62 63 64 |
# File 'lib/fino/setting.rb', line 62 def type_class definition.type_class end |
#value(**context) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fino/setting.rb', line 37 def value(**context) return global_value unless (scope = context[:for]) overrides.fetch(scope.to_s) do return global_value unless experiment value = experiment.value(for: scope) return global_value if value == Fino::AbTesting::Variant::CONTROL_VALUE value end end |