Module: KindeSdk::Client::FeatureFlags
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.
Methods included from Logging
#log_debug, #log_error, #log_info, #log_warning, resolve_logger, write_log
Instance Method Details
#get_boolean_flag(name, default_value = nil) ⇒ Object
Legacy methods for backward compatibility
71 72 73 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 71 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
47 48 49 50 51 52 53 54 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 47 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?)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 21 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
79 80 81 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 79 def get_integer_flag(name, default_value = nil) flag_getter_wrapper(name, "i", default_value) end |
#get_string_flag(name, default_value = nil) ⇒ Object
75 76 77 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 75 def get_string_flag(name, default_value = nil) flag_getter_wrapper(name, "s", default_value) end |
#getFlags ⇒ Object
PHP SDK compatible alias
84 85 86 87 88 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 84 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
61 62 63 64 65 66 67 68 |
# File 'lib/kinde_sdk/client/feature_flags.rb', line 61 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 |