Module: Lich::Common::InstanceSettings
- Defined in:
- documented/common/settings/instance_settings.rb
Constant Summary collapse
- SCRIPT_NAME =
Script name used for core Lich functionality This allows Settings API to work without Script.current context
'core'
Class Method Summary collapse
-
.[](name) ⇒ OpenStruct
Retrieves a setting value by name for the current character scope.
-
.[]=(name, value) ⇒ Object
Sets a setting value by name for the current character scope.
-
.character_proxy ⇒ OpenStruct
Provides a proxy for accessing character-scoped settings.
-
.character_scope ⇒ String
Returns the character scope string for settings access.
-
.game ⇒ OpenStruct
Provides access to game-scoped settings.
-
.game_proxy ⇒ OpenStruct
Provides a proxy for accessing game-scoped settings.
-
.game_scope ⇒ String
Returns the game scope string for settings access.
-
.load ⇒ nil
deprecated
Deprecated.
This method is not applicable.
-
.save ⇒ nil
deprecated
Deprecated.
This method is not applicable.
-
.to_hash ⇒ Hash
Converts the character-scoped settings to a hash.
Class Method Details
.[](name) ⇒ OpenStruct
Retrieves a setting value by name for the current character scope.
49 50 51 |
# File 'documented/common/settings/instance_settings.rb', line 49 def self.[](name) Settings.get_scoped_setting(character_scope, name, script_name: SCRIPT_NAME) end |
.[]=(name, value) ⇒ Object
Sets a setting value by name for the current character scope.
57 58 59 |
# File 'documented/common/settings/instance_settings.rb', line 57 def self.[]=(name, value) Settings.set_script_settings(character_scope, name, value, script_name: SCRIPT_NAME) end |
.character_proxy ⇒ OpenStruct
Provides a proxy for accessing character-scoped settings.
64 65 66 |
# File 'documented/common/settings/instance_settings.rb', line 64 def self.character_proxy Settings.root_proxy_for(character_scope, script_name: SCRIPT_NAME) end |
.character_scope ⇒ String
Returns the character scope string for settings access.
34 35 36 |
# File 'documented/common/settings/instance_settings.rb', line 34 def self.character_scope "#{XMLData.game}:#{XMLData.name}" end |
.game ⇒ OpenStruct
Provides access to game-scoped settings.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'documented/common/settings/instance_settings.rb', line 78 def self.game @game_accessor ||= Module.new do extend self def self.[](name) InstanceSettings.game_proxy[name] end def self.[]=(name, value) proxy = InstanceSettings.game_proxy proxy[name] = value end def self.to_hash Settings.current_script_settings( InstanceSettings.game_scope, script_name: InstanceSettings::SCRIPT_NAME ) end end end |
.game_proxy ⇒ OpenStruct
Provides a proxy for accessing game-scoped settings.
71 72 73 |
# File 'documented/common/settings/instance_settings.rb', line 71 def self.game_proxy Settings.root_proxy_for(game_scope, script_name: SCRIPT_NAME) end |
.game_scope ⇒ String
Returns the game scope string for settings access.
41 42 43 |
# File 'documented/common/settings/instance_settings.rb', line 41 def self.game_scope XMLData.game end |
.load ⇒ nil
This method is not applicable.
Loads instance settings (deprecated).
116 117 118 119 |
# File 'documented/common/settings/instance_settings.rb', line 116 def self.load Lich.deprecated('InstanceSettings.load', 'not using, not applicable,', caller[0], fe_log: true) nil end |
.save ⇒ nil
This method is not applicable.
Saves instance settings (deprecated).
125 126 127 128 |
# File 'documented/common/settings/instance_settings.rb', line 125 def self.save Lich.deprecated('InstanceSettings.save', 'not using, not applicable,', caller[0], fe_log: true) nil end |
.to_hash ⇒ Hash
Converts the character-scoped settings to a hash.
103 104 105 106 107 108 109 110 |
# File 'documented/common/settings/instance_settings.rb', line 103 def self.to_hash Settings.wrap_value_if_container( Settings.current_script_settings(character_scope, script_name: SCRIPT_NAME), character_scope, [], script_name: SCRIPT_NAME ) end |