-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36cbc5b
commit b606834
Showing
4 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Menu | ||
class SettingsLoader < YamlLoader | ||
include Singleton | ||
|
||
def self.load | ||
instance.load_from_settings | ||
end | ||
|
||
def load_from_settings | ||
@sections = [] | ||
@items = [] | ||
begin | ||
binding.pry | ||
settings = ::Settings.ui.custom_menu | ||
(settings || []).each do |i| | ||
load_custom_item(i) | ||
end | ||
rescue => e # if we encounter an error while loading the menus, we ignore the whole settings | ||
$log.error("Error loading custom menu from settings: #{e}") | ||
$log.error("Settings were: #{settings}") | ||
return [[], []] | ||
end | ||
[@sections, @items] | ||
end | ||
|
||
private | ||
|
||
def load_custom_item(properties) | ||
if properties['type'] == 'section' | ||
@sections << create_custom_menu_section(properties) | ||
else | ||
@items << create_custom_menu_item(properties) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters