Class: Rho::RhoConfig
- Defined in:
- lib/framework/rho/rho.rb,
lib/framework/autocomplete/Rho.rb
Overview
Generic configuration class which accepts hashes with unique keys
Constant Summary collapse
- @@sources =
{}
- @@max_config_srcid =
@@config = => ‘/app’, ‘options_path’ => ‘/app/Settings’
{}
- @@cached_changed =
nil
- @@g_base_temp_id =
nil
Class Method Summary collapse
- .add_loaded_source(modelname, new_source) ⇒ Object
-
.add_source(modelname, props) ⇒ Object
def add_config(key,value) @@config = value if key # allow nil value end.
- .clean_cached_changed ⇒ Object
- .exists?(name) ⇒ Boolean
- .generate_id ⇒ Object
-
.max_config_srcid ⇒ Object
def reload @@config = => ‘/app’, ‘options_path’ => ‘/app/Settings’ Rho::RHO.process_rhoconfig end.
- .method_missing(name, args) ⇒ Object
- .read_log(limit) ⇒ Object
- .send_log ⇒ Object
- .show_log ⇒ Object
- .source_changed?(name, partition) ⇒ Boolean
- .sources ⇒ Object
Class Method Details
.add_loaded_source(modelname, new_source) ⇒ Object
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 |
# File 'lib/framework/rho/rho.rb', line 1149 def add_loaded_source(modelname, new_source=nil) return if !modelname || modelname.length() == 0# || @@sources[modelname] puts "#{modelname} : #{new_source}" @@sources[modelname] = new_source ? new_source.clone() : {} @@sources[modelname]['name'] ||= modelname @@sources[modelname][:loaded] = true if @@sources[modelname]['sync_priority'] @@sources[modelname]['sync_priority'] = @@sources[modelname]['sync_priority'].to_i() else @@sources[modelname]['sync_priority'] = 1000 end #@@sources[modelname]['sync_type'] = 'none' if !@@sources[modelname]['sync'] @@sources[modelname]['sync_type'] ||= 'none' if @@sources[modelname]['partition'] @@sources[modelname]['partition'] = @@sources[modelname]['partition'].to_s else @@sources[modelname]['partition'] ||= @@sources[modelname]['sync_type'] != 'none' ? 'user' : 'local' end if @@sources[modelname]['source_id'] @@sources[modelname]['source_id'] = @@sources[modelname]['source_id'].to_i() end @@max_config_srcid[@@sources[modelname]['partition']] = @@sources[modelname]['source_id'] if @@sources[modelname]['source_id'] && @@max_config_srcid[@@sources[modelname]['partition']] < @@sources[modelname]['source_id'] end |
.add_source(modelname, props) ⇒ Object
def add_config(key,value)
@@config[key] = value if key # allow nil value
end
1144 1145 1146 1147 |
# File 'lib/framework/rho/rho.rb', line 1144 def add_source(modelname, props) @@sources[modelname] = props @@sources[modelname]['name'] ||= modelname end |
.clean_cached_changed ⇒ Object
1106 1107 1108 |
# File 'lib/framework/rho/rho.rb', line 1106 def clean_cached_changed @@cached_changed = nil end |
.exists?(name) ⇒ Boolean
1076 1077 1078 |
# File 'lib/framework/rho/rho.rb', line 1076 def exists?(name) RhoConf.is_property_exists(name) end |
.generate_id ⇒ Object
1180 1181 1182 1183 1184 1185 |
# File 'lib/framework/rho/rho.rb', line 1180 def generate_id @@g_base_temp_id = ((Time.now.to_f - Time.mktime(2009,"jan",1,0,0,0,0).to_f) * 10**6) unless @@g_base_temp_id @@g_base_temp_id = @@g_base_temp_id + 1 @@g_base_temp_id end |
.max_config_srcid ⇒ Object
1085 1086 1087 |
# File 'lib/framework/rho/rho.rb', line 1085 def max_config_srcid @@max_config_srcid end |
.method_missing(name, args) ⇒ Object
1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File 'lib/framework/rho/rho.rb', line 1066 def method_missing(name, *args) unless name == Fixnum if name[name.length()-1] == '=' RhoConf.set_property_by_name(name.to_s.chop,args[0] ? args[0].to_s : "") else RhoConf.get_property_by_name(name.to_s) end end end |
.read_log(limit) ⇒ Object
1097 1098 1099 |
# File 'lib/framework/rho/rho.rb', line 1097 def read_log(limit=0) RhoConf.read_log(limit) end |
.send_log ⇒ Object
1093 1094 1095 |
# File 'lib/framework/rho/rho.rb', line 1093 def send_log RhoConf.send_log end |
.show_log ⇒ Object
1089 1090 1091 |
# File 'lib/framework/rho/rho.rb', line 1089 def show_log RhoConf.show_log end |
.source_changed?(name, partition) ⇒ Boolean
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 |
# File 'lib/framework/rho/rho.rb', line 1110 def source_changed?(name, partition='user') return Object.const_get(name).changed?() if Object.const_defined?(name) if !@@cached_changed @@cached_changed = {} db = ::Rho::RHO.get_db_partitions[partition] db_ids = db.execute_sql("SELECT source_id,name FROM sources" ) changes = db.execute_sql("SELECT DISTINCT(source_id) FROM changed_values" ) changes.each do |changed_item| changed_name = nil db_ids.each do |db_item| if db_item['source_id'] == changed_item['source_id'] changed_name = db_item['name'] break end end @@cached_changed[changed_name] = true if changed_name end end @@cached_changed.has_key?(name) ? @@cached_changed[name] : false end |
.sources ⇒ Object
1101 1102 1103 |
# File 'lib/framework/rho/rho.rb', line 1101 def sources @@sources end |