Module: KindeSdk::Client::FeatureFlags
- Included in:
- KindeSdk::Client
- Defined in:
- lib/kinde_sdk/client/feature_flags.rb
Instance Method Summary collapse
-
#get_boolean_flag(name, default_value = nil) ⇒ Object
Legacy methods for backward compatibility.
-
#get_flag(name, options_or_opts = {}, flag_type = nil) ⇒ Hash?
Get a specific feature flag Supports both new API-style calls and legacy 3-parameter calls.
-
#get_flags(options = {}) ⇒ Array
Get all feature flags for the authenticated user Matches the JavaScript SDK API: getFlags(options?).
- #get_integer_flag(name, default_value = nil) ⇒ Object
- #get_string_flag(name, default_value = nil) ⇒ Object
-
#getFlags ⇒ Object
PHP SDK compatible alias.
-
#has_feature_flags?(flag_conditions, options = {}) ⇒ Boolean
(also: #hasFeatureFlags)
Check if user has specific feature flags.
Instance Method Details
#get_boolean_flag(name, default_value = nil) ⇒ Object
Legacy methods for backward compatibility
70 71 72 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 70 def get_boolean_flag(name, default_value = nil) flag_getter_wrapper(name, "b", default_value) end |
#get_flag(name, options_or_opts = {}, flag_type = nil) ⇒ Hash?
Get a specific feature flag Supports both new API-style calls and legacy 3-parameter calls
46 47 48 49 50 51 52 53 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 46 def get_flag(name, = {}, flag_type = nil) # Handle legacy 3-parameter signature: get_flag(name, opts, flag_type) if flag_type || (.is_a?(Hash) && .key?(:default_value) && !.key?(:force_api)) return get_flag_legacy(name, , flag_type) end get_flag_new_api(name, ) end |
#get_flags(options = {}) ⇒ Array
Get all feature flags for the authenticated user Matches the JavaScript SDK API: getFlags(options?)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 20 def get_flags( = {}) # Handle legacy positional argument for backward compatibility if .is_a?(Symbol) = { token_type: } end # Extract options with defaults - use member variable if not overridden force_api = [:force_api] || @force_api || false token_type = [:token_type] || :access_token if force_api # Hard check - call API for fresh flags get_flags_from_api else # Soft check - extract from token claims get_flags_from_token(token_type) end end |
#get_integer_flag(name, default_value = nil) ⇒ Object
78 79 80 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 78 def get_integer_flag(name, default_value = nil) flag_getter_wrapper(name, "i", default_value) end |
#get_string_flag(name, default_value = nil) ⇒ Object
74 75 76 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 74 def get_string_flag(name, default_value = nil) flag_getter_wrapper(name, "s", default_value) end |
#getFlags ⇒ Object
PHP SDK compatible alias
83 84 85 86 87 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 83 def getFlags # Use client's force_api setting, default to true for PHP SDK compatibility force_api_setting = @force_api.nil? ? true : @force_api get_flags(force_api: force_api_setting) end |
#has_feature_flags?(flag_conditions, options = {}) ⇒ Boolean Also known as: hasFeatureFlags
Check if user has specific feature flags
60 61 62 63 64 65 66 67 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 60 def has_feature_flags?(flag_conditions, = {}) return true if flag_conditions.nil? || flag_conditions.empty? flags = get_flags() flag_conditions_array = Array(flag_conditions) flag_conditions_array.all? { |condition| check_flag_condition(condition, flags) } end |