Class: Preference
- Inherits:
-
Settingslogic
- Object
- Settingslogic
- Preference
- Defined in:
- app/models/preference.rb
Constant Summary collapse
- BOOLEAN_FIELD_REGEXP =
/(enabled|disabled)/
Class Method Summary collapse
- .admin_defaults ⇒ Object
- .admin_preference_names ⇒ Object
- .general_preference_names ⇒ Object
- .make_toolbox_name_to_preference_names_hash ⇒ Object
- .toolbox_names ⇒ Object
- .toolbox_preference_names ⇒ Object
- .user_defaults ⇒ Object
- .whole_preference_names ⇒ Object
Instance Method Summary collapse
-
#initialize(hash_or_file = self.class.source, section = nil) ⇒ Preference
constructor
A new instance of Preference.
Constructor Details
#initialize(hash_or_file = self.class.source, section = nil) ⇒ Preference
Returns a new instance of Preference.
76 77 78 79 80 81 82 |
# File 'app/models/preference.rb', line 76 def initialize(hash_or_file = self.class.source, section = nil) super rescue NoMethodError replace({}) @section = section || self.class.source create_accessors! end |
Class Method Details
.admin_defaults ⇒ Object
49 50 51 |
# File 'app/models/preference.rb', line 49 def admin_defaults make_defaults(admin_preference_names) end |
.admin_preference_names ⇒ Object
32 33 34 35 36 |
# File 'app/models/preference.rb', line 32 def admin_preference_names %w( enabled_must_signin ) end |
.general_preference_names ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/models/preference.rb', line 23 def general_preference_names %w( disabled_add_character_from_beginning disabled_new_character enabled_readonly_ruby_mode hardware_port ) end |
.make_toolbox_name_to_preference_names_hash ⇒ Object
53 54 55 56 57 |
# File 'app/models/preference.rb', line 53 def make_toolbox_name_to_preference_names_hash toolbox_preference_names.group_by { |n| n.slice(/^toolbox__(.+?)__/, 1) } end |
.toolbox_names ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/models/preference.rb', line 7 def toolbox_names %w( default smalrubot_v3 smalrubot_s1 ) end |
.toolbox_preference_names ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/models/preference.rb', line 15 def toolbox_preference_names %w( toolbox__default__enabled_hardware_blocks toolbox__default__enabled_smalrubot_v3_blocks toolbox__default__enabled_smalrubot_s1_blocks ) end |
.user_defaults ⇒ Object
43 44 45 46 47 |
# File 'app/models/preference.rb', line 43 def user_defaults make_defaults(toolbox_preference_names + general_preference_names) .merge("toolbox_name" => "default") end |
.whole_preference_names ⇒ Object
38 39 40 41 |
# File 'app/models/preference.rb', line 38 def whole_preference_names ["toolbox_name"] + toolbox_preference_names + general_preference_names + admin_preference_names end |