| Class | ApplicationModuleOption |
| In: |
app/models/application_module_option.rb
|
| Parent: | ActiveRecord::Base |
API for interaction with the database table ‘application_module_options’, and it‘s related data model.
Populate variables for all module options.
Variables use indices of the following format:
For example:
# File app/models/application_module_option.rb, line 34
34: def self.compose (
35: data_type,
36: data_id,
37: index
38: )
39: for option in find_all_by_data_type_and_data_id(data_type, data_id)
40: case option.value
41: when 'TRUE'
42: value = TRUE
43: when 'FALSE'
44: value = FALSE
45: else
46: value = option.value
47: end
48:
49: # Construct the index that will be used for the value of this option.
50: name = $modules[option.application_module_id] + ':' + option.name
51:
52: # Store this option's value, and "updated_on" information.
53: $o[index] = {} if (!$o[index])
54: $o[index][name] = {}
55: $o[index][name]['value'] = value
56: $o[index][name]['updated_on'] = option.updated_on
57: end
58: end
Construct variables for module options:
1. Obtain all options for the default project (Code Blue)
2. Obtain all options for this project, overwriting any existing options with project specific values (which is faster than performing an array test to determine if an index exists and then adding/updating an element)
3. Obtain all options for this project host, overwriting any existing options with host specific values.
4. Obtain all options for this project page, overwriting any existing options with page specific values.
# File app/models/application_module_option.rb, line 80
80: def self.get (
81: project_id,
82: project_host_id,
83: project_page_id
84: )
85: # Create this page's index, as used with the global hash variable $o.
86: index = project_id.to_s + '.' + project_host_id.to_s
87: index += '.' + project_page_id.to_s if (project_page_id)
88:
89: if (!$o[index])
90: load_modules
91:
92: data_types = []
93: data_types << ['project', DEFAULT_PROJECT_ID]
94: data_types << ['project', project_id]
95: data_types << ['project_host', project_host_id]
96: data_types << ['project_page', project_page_id]
97: data_types.each { |type| compose(type[0], type[1], index) }
98: end
99:
100: # Save this page's module option index.
101: g('application', 'module_option_index', index)
102: end
Construct a map of modules to their database row ids.
# File app/models/application_module_option.rb, line 108
108: def self.load_modules
109: if (!$modules || 0 == $modules.size)
110: for application_module in find_by_sql('SELECT * FROM application_modules')
111: index = application_module.model + ':' + application_module.component
112: $modules[application_module.id] = index
113: end
114: end
115: end