Class: ManagerWithJsonData
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from ManagerBase
#cleanup_data, #invalidate_cache, #on_data_loaded, #on_server_maintenance_on, #on_server_shutdown, #on_server_started, #start_tasks
Constructor Details
30
31
32
33
34
|
# File 'lib/mrpin/core/with_json/manager_with_json_data.rb', line 30
def initialize(options = nil)
super(options)
@url_client_data = nil
end
|
Instance Attribute Details
#url_client_data ⇒ Object
7
8
9
|
# File 'lib/mrpin/core/with_json/manager_with_json_data.rb', line 7
def url_client_data
@url_client_data
end
|
Instance Method Details
#generate_client_json ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/mrpin/core/with_json/manager_with_json_data.rb', line 74
def generate_client_json
unless @url_client_data.nil?
file_path = UtilsIO.to_local_path(@url_client_data)
File.delete(file_path) if File.exist?(file_path)
end
file_content_json = self.get_json_data_client
data_client_folder = File.join(@root_dir, self.data_client_folder)
FileUtils.mkdir_p(data_client_folder)
file_name = File.join(data_client_folder, self.data_client_filename)
file_name += '_' + Time.now.to_i.to_s + '.json'
File.write(file_name, file_content_json)
@url_client_data = UtilsIO.to_domain_path(file_name)
nil
end
|
#load_init_data ⇒ Object
46
47
48
49
50
|
# File 'lib/mrpin/core/with_json/manager_with_json_data.rb', line 46
def load_init_data
super
check_json_data_client
end
|
#post_init ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/mrpin/core/with_json/manager_with_json_data.rb', line 37
def post_init
super
@root_dir = Rails.env.development? ? File.join(Rails.root.to_s, 'public') : "/usr/local/#{AppInfo.instance.server_name}"
nil
end
|