Class: Foobara::RemoteGenerator::Services::CommandResultGenerator
- Inherits:
-
CommandGenerator
show all
- Defined in:
- foobara-typescript-remote-command-generator-1.2.0/src/remote_generator/services/command_result_generator.rb
Constant Summary
TruncatedInspect::MAX_LENGTH
Instance Attribute Summary
#belongs_to_dependency_group, #relevant_manifest
Instance Method Summary
collapse
#base_class_name, #base_class_path, #command_errors_index_generator, #domain_generator, #errors_in_this_namespace, #result_json_requires_cast?
#==, #attributes_to_ts_type, #custom_type_to_ts_type_name, #dependency_group, #dependency_roots, #foobara_type_to_ts_type, #hash, #import_destructure, #import_path, #import_path_array, #initialize, manifest_to_generator_classes, #model_to_ts_model_name, #parent, #path_to_root, #templates_dir, #ts_instance_full_name, #ts_instance_full_path, #ts_instance_path, #ts_type_full_path, #value_to_ts_value
#==, #absolute_template_path, #applicable?, #dependencies_to_generate, #eql?, #erb_template, #generate, generator_for, #generator_for, generators_for, #generators_for, #hash, #initialize, manifest_to_generator_classes, #method_missing, #path_to_root, #respond_to_missing?, #target_dir, #template_string, #templates_dir
#inspect, truncating
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Foobara::FilesGenerator
Instance Method Details
#aggregate? ⇒ Boolean
102
103
104
|
# File 'src/remote_generator/services/command_result_generator.rb', line 102
def aggregate?
serializers&.any? { |s| s == "Foobara::CommandConnectors::Serializers::AggregateSerializer" }
end
|
#association_depth ⇒ Object
#atom? ⇒ Boolean
98
99
100
|
# File 'src/remote_generator/services/command_result_generator.rb', line 98
def atom?
serializers&.any? { |s| s == "Foobara::CommandConnectors::Serializers::AtomicSerializer" }
end
|
#dependencies ⇒ Object
116
117
118
|
# File 'src/remote_generator/services/command_result_generator.rb', line 116
def dependencies
model_generators + type_generators
end
|
#model_generators(*args) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'src/remote_generator/services/command_result_generator.rb', line 21
def model_generators(*args)
type, initial = if args.empty?
return @model_generators if defined?(@model_generators)
use_cache = true
[result_type, true]
else
args
end
if type.nil?
[]
elsif type.detached_entity?
generator_class = if atom?
if initial
AtomEntityGenerator
else
UnloadedEntityGenerator
end
elsif aggregate?
AggregateEntityGenerator
else
TypeGenerator
end
entity = if type.entity?
type.to_entity
else
type.to_detached_entity
end
[generator_class.new(entity)]
elsif type.model?
generator_class = if atom?
AtomModelGenerator
elsif aggregate?
AggregateModelGenerator
else
TypeGenerator
end
[generator_class.new(type.to_model)]
elsif type.type.to_sym == :attributes
type.attribute_declarations.values.map do |attribute_declaration|
model_generators(attribute_declaration, false)
end.flatten.uniq
elsif type.array?
model_generators(type.element_type, false)
else
[]
end.tap do |result|
if use_cache
@model_generators = result
end
end
end
|
#result_type ⇒ Object
9
10
11
|
# File 'src/remote_generator/services/command_result_generator.rb', line 9
def result_type
command_manifest.result_type
end
|
#target_path ⇒ Object
13
14
15
|
# File 'src/remote_generator/services/command_result_generator.rb', line 13
def target_path
[*scoped_full_path, "Result.ts"]
end
|
#template_path ⇒ Object
17
18
19
|
# File 'src/remote_generator/services/command_result_generator.rb', line 17
def template_path
"Command/Result.ts.erb"
end
|
#type_generators ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'src/remote_generator/services/command_result_generator.rb', line 82
def type_generators
@type_generators ||= begin
type = result_type
type = type.to_type if result_type.is_a?(Manifest::TypeDeclaration)
if type && !type.builtin? && !type.model?
[TypeGenerator.new(type)]
else
[]
end
end
end
|