Class: ThemeSettingsManager::Objects
Instance Attribute Summary
#default, #name, #theme
Class Method Summary
collapse
Instance Method Summary
collapse
cast, cast_row_value, create, #create_record!, #db_record, #description, #ensure_is_valid_value!, #has_max?, #has_min?, #has_record?, #initialize, #requests_refresh?, #type, #type_name, types, #update_record!
Class Method Details
4
5
6
|
# File 'lib/theme_settings_manager/objects.rb', line 4
def self.(row)
row.json_value
end
|
Instance Method Details
#categories(guardian) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/theme_settings_manager/objects.rb', line 24
def categories(guardian)
category_ids = Set.new
value.each do |theme_setting_object|
category_ids.merge(
ThemeSettingsObjectValidator.new(
schema:,
object: theme_setting_object,
).property_values_of_type("categories"),
)
end
return [] if category_ids.empty?
Category.secured(guardian).where(id: category_ids)
end
|
#schema ⇒ Object
20
21
22
|
# File 'lib/theme_settings_manager/objects.rb', line 20
def schema
@opts[:schema]
end
|
#value ⇒ Object
8
9
10
|
# File 'lib/theme_settings_manager/objects.rb', line 8
def value
has_record? ? db_record.json_value : default.map!(&:deep_stringify_keys)
end
|
#value=(objects) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/theme_settings_manager/objects.rb', line 12
def value=(objects)
objects = JSON.parse(objects) if objects.is_a?(::String)
ensure_is_valid_value!(objects)
record = has_record? ? update_record!(json_value: objects) : create_record!(json_value: objects)
theme.reload
record.json_value
end
|