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
|
# File 'lib/choron_support/helper.rb', line 6
def generate_choron_class(namespaces, model_name, class_symbol, exception: true)
namespace = if namespaces.is_a?(Array)
namespaces.join("::")
else
namespaces.to_s
end
unless model_name.to_s.empty?
namespace = "#{namespaces}::#{model_name.pluralize}"
end
target_class_name = "#{namespace}::#{class_symbol.to_s.camelize}"
if target_class_name.end_with?("?") || target_class_name.end_with?("!")
target_class_name.chop!
end
target_class = nil
begin
target_class = target_class_name.constantize
rescue NameError => e
if exception
raise e
end
end
target_class
end
|