2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/listly/load_lists.rb', line 2
def self.load
Listly.include_constants_module
Listly.list_name_constants.each do |name, store_hash|
list_module = Module.new
new_module_name = Listly.module_name_for_list_name(name)
list_module.module_eval do
include Listly::BaseList
define_method(:storage_location) { store_hash }
define_method("all_#{name.to_s.underscore.pluralize}") {
all_list_items(name.to_s.underscore.to_sym,
"#{new_module_name}::My#{new_module_name}", I18n.t("#{store_hash}"))
}
define_method("#{name.to_s.underscore}_name") {
list_item_name(Module.const_get("all_#{name.to_s.underscore.pluralize}"),
"#{name.to_s.underscore}_code".to_sym, "#{name.to_s.underscore}_name".to_sym,
list_item_code)
}
end
klass = Class.new(Listly::BaseList::MyListType)
klass.send(:define_method, :code) { code }
class_name = "My#{new_module_name}"
list_module.const_set(class_name, klass)
Listly.const_set(new_module_name, list_module)
end
end
|