Class: Lanes::SystemSettings
- Inherits:
-
Model
- Object
- ActiveRecord::Base
- Model
- Lanes::SystemSettings
show all
- Defined in:
- lib/lanes/system_settings.rb
Defined Under Namespace
Classes: ExtensionSettings
Constant Summary
Concerns::ApiAttributeAccess::DEFAULT_BLACKLISTED
Class Method Summary
collapse
Instance Method Summary
collapse
#_set_attribute_data_from_collection, #set_attribute_data, #setting_attribute_is_allowed?
Class Method Details
.clear_cache!(msg) ⇒ Object
76
77
78
79
|
# File 'lib/lanes/system_settings.rb', line 76
def clear_cache!(msg)
Lanes.logger.debug "SystemSettings cache reset"
Lanes::SystemSettings.instance_variable_set(:@config, nil)
end
|
.config ⇒ Object
39
40
41
|
# File 'lib/lanes/system_settings.rb', line 39
def config
@config ||= SystemSettings.find_or_create_by(id: Lanes.config.configuration_id)
end
|
.for_ext(extension_id) ⇒ Object
43
44
45
|
# File 'lib/lanes/system_settings.rb', line 43
def for_ext(extension_id)
ExtensionSettings.new(extension_id, config.settings[extension_id.to_s])
end
|
.get_handler ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/lanes/system_settings.rb', line 53
def get_handler
lambda do
wrap_reply do
std_api_reply :get,
Lanes::SystemSettings.config.as_json(
include: ['logo', 'print_logo']
)
end
end
end
|
.on_change(extension_id, call_now: false, &block) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/lanes/system_settings.rb', line 81
def on_change(extension_id, call_now: false, &block)
Thread.new do
Lanes.redis_connection(cache:false).subscribe(
'lanes-system-configuration-update') do |on|
on.message do |channel, msg|
ActiveRecord::Base.connection_pool.with_connection do
yield SystemSettings.for_ext(extension_id)
end
end
end
end
end
|
.persist!(extension_id, update) ⇒ Object
47
48
49
50
51
|
# File 'lib/lanes/system_settings.rb', line 47
def persist!(extension_id, update)
config.settings[extension_id] = update
config.settings_will_change!
config.save!
end
|
.update_handler ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/lanes/system_settings.rb', line 64
def update_handler
lambda do
wrap_reply do
config = SystemSettings.config
if data['settings'].is_a?(Hash)
config.update_attributes!(settings: data['settings'])
end
std_api_reply :update, { settings: config.settings }, success: true
end
end
end
|
Instance Method Details
#notify_updated ⇒ Object
34
35
36
|
# File 'lib/lanes/system_settings.rb', line 34
def notify_updated
Lanes.redis_connection.publish('lanes-system-configuration-update', self.id)
end
|