Class: Flagsmith::Flags::Flag
Instance Attribute Summary collapse
Attributes inherited from BaseFlag
#default, #enabled, #value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseFlag
#enabled?
Constructor Details
#initialize(feature_name:, enabled:, value:, feature_id:) ⇒ Flag
Returns a new instance of Flag.
35
36
37
38
39
|
# File 'lib/flagsmith/sdk/models/flags.rb', line 35
def initialize(feature_name:, enabled:, value:, feature_id:)
super(enabled: enabled, value: value, default: false)
@feature_name = feature_name
@feature_id = feature_id
end
|
Instance Attribute Details
#feature_id ⇒ Object
Returns the value of attribute feature_id.
33
34
35
|
# File 'lib/flagsmith/sdk/models/flags.rb', line 33
def feature_id
@feature_id
end
|
#feature_name ⇒ Object
Returns the value of attribute feature_name.
33
34
35
|
# File 'lib/flagsmith/sdk/models/flags.rb', line 33
def feature_name
@feature_name
end
|
Class Method Details
.from_api(json_flag_data) ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/flagsmith/sdk/models/flags.rb', line 69
def from_api(json_flag_data)
new(
enabled: json_flag_data[:enabled],
value: json_flag_data[:feature_state_value] || json_flag_data[:value],
feature_name: json_flag_data.dig(:feature, :name),
feature_id: json_flag_data.dig(:feature, :id)
)
end
|
.from_feature_state_model(feature_state_model, identity_id) ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/flagsmith/sdk/models/flags.rb', line 60
def from_feature_state_model(feature_state_model, identity_id)
new(
enabled: feature_state_model.enabled,
value: feature_state_model.get_value(identity_id),
feature_name: feature_state_model.feature.name,
feature_id: feature_state_model.feature.id
)
end
|
Instance Method Details
#<=>(other) ⇒ Object
41
42
43
|
# File 'lib/flagsmith/sdk/models/flags.rb', line 41
def <=>(other)
feature_name <=> other.feature_name
end
|
#[](key) ⇒ Object
45
46
47
|
# File 'lib/flagsmith/sdk/models/flags.rb', line 45
def [](key)
to_h[key]
end
|
#to_h ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/flagsmith/sdk/models/flags.rb', line 49
def to_h
{
feature_id: feature_id,
feature_name: feature_name,
value: value,
enabled: enabled,
default: default
}
end
|