Skip to content

Commit

Permalink
🐛 Fix settings proxy objects
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Nov 28, 2024
1 parent a9b0840 commit ca0621d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Fix `_modelInstance` cache when keys are not strings
* Fix certain settings not being applied if they're created after generating the main system setting object
* Fix settings proxy objects

## 1.4.0-alpha.7 (2024-10-10)

Expand Down
50 changes: 48 additions & 2 deletions lib/core/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -1734,15 +1734,61 @@ const MagicGroupValue = Function.inherits('Magic', 'Alchemy.Setting', function M
*/
MagicGroupValue.setMethod(function __get(key) {

let result = this[VALUE].get(key);
let result = this[key];

if (result != null) {
return result;
}

result = this[VALUE].get(key);

if (result == null) {
return this[VALUE][key];
}

if (!result) {
return;
return result;
}

if (result.is_group) {
return result.toProxyObject();
}

if (!result.get) {
return result;
}

return result.get();
});

/**
* The magic getter
*
* @author Jelle De Loecker <[email protected]>
* @since 1.4.0
* @version 1.4.0
*
* @param {string} key
*/
MagicGroupValue.setMethod(function __ownKeys() {
return Object.keys(this[VALUE].toObject())
});

/**
* The magic getter
*
* @author Jelle De Loecker <[email protected]>
* @since 1.4.0
* @version 1.4.0
*
* @param {string} key
*/
MagicGroupValue.setMethod(function __describe(key) {
let result = Object.getOwnPropertyDescriptor(this[VALUE], key);

if (result == null) {
result = Object.getOwnPropertyDescriptor(this, key);
}

return result;
});

0 comments on commit ca0621d

Please sign in to comment.