Class: Gitlab::FakeApplicationSettings

Inherits:
Object
  • Object
show all
Includes:
ApplicationSettingImplementation
Defined in:
lib/gitlab/fake_application_settings.rb

Constant Summary

Constants included from ApplicationSettingImplementation

ApplicationSettingImplementation::DEFAULT_MINIMUM_PASSWORD_LENGTH, ApplicationSettingImplementation::DEFAULT_PROTECTED_PATHS, ApplicationSettingImplementation::FORBIDDEN_KEY_VALUE, ApplicationSettingImplementation::STRING_LIST_SEPARATOR, ApplicationSettingImplementation::VALID_RUNNER_REGISTRAR_TYPES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApplicationSettingImplementation

#add_to_outbound_local_requests_whitelist, #allow_signup?, #allowed_key_types, #archive_builds_older_than, #asset_proxy_allowlist, #asset_proxy_whitelist=, #commit_email_hostname, #default_group_visibility=, #default_project_visibility=, #default_snippet_visibility=, #disabled_oauth_sign_in_sources=, #domain_allowlist_raw, #domain_allowlist_raw=, #domain_denylist_file=, #domain_denylist_raw, #domain_denylist_raw=, #ensure_key_restrictions!, #error_tracking_access_token, #health_check_access_token, #help_page_support_url_column_exists?, #home_page_url_column_exists?, #key_restriction_for, #latest_terms, #normalized_repository_storage_weights, #notes_create_limit_allowlist_raw, #notes_create_limit_allowlist_raw=, #outbound_local_requests_allowlist_arrays, #outbound_local_requests_allowlist_raw, #outbound_local_requests_allowlist_raw=, #password_authentication_enabled?, #performance_bar_allowed_group, #performance_bar_enabled, #pick_repository_storage, #protected_paths_for_get_request_raw, #protected_paths_for_get_request_raw=, #protected_paths_raw, #protected_paths_raw=, #repository_storages, #reset_memoized_terms, #restricted_visibility_levels=, #runners_registration_token, #search_rate_limit_allowlist_raw, #search_rate_limit_allowlist_raw=, #static_objects_external_storage_auth_token=, #static_objects_external_storage_enabled?, #usage_ping_can_be_configured?, #usage_ping_enabled, #usage_ping_features_enabled?, #user_default_internal_regex_enabled?, #user_default_internal_regex_instance, #users_get_by_id_limit_allowlist_raw, #users_get_by_id_limit_allowlist_raw=

Constructor Details

#initialize(settings = {}) ⇒ FakeApplicationSettings

Returns a new instance of FakeApplicationSettings.



30
31
32
33
34
# File 'lib/gitlab/fake_application_settings.rb', line 30

def initialize(settings = {})
  @table = settings.dup

  FakeApplicationSettings.define_properties(settings)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject

Mimic behavior of OpenStruct, which absorbs any calls into undefined properties to return ‘nil`.



46
47
48
# File 'lib/gitlab/fake_application_settings.rb', line 46

def method_missing(*)
  nil
end

Class Method Details

.define_properties(settings) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/fake_application_settings.rb', line 12

def self.define_properties(settings)
  settings.each do |key, value|
    define_method key do
      read_attribute(key)
    end

    if [true, false].include?(value)
      define_method "#{key}?" do
        read_attribute(key)
      end
    end

    define_method "#{key}=" do |v|
      @table[key.to_sym] = v
    end
  end
end

Instance Method Details

#has_attribute?(key) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/gitlab/fake_application_settings.rb', line 40

def has_attribute?(key)
  @table.key?(key.to_sym)
end

#read_attribute(key) ⇒ Object



36
37
38
# File 'lib/gitlab/fake_application_settings.rb', line 36

def read_attribute(key)
  @table[key.to_sym]
end