Class: Foobara::RemoteGenerator::Services::CommandResultGenerator
Constant Summary
TruncatedInspect::MAX_LENGTH
Instance Attribute Summary
#belongs_to_dependency_group, #relevant_manifest
Instance Method Summary
collapse
#==, #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
86
87
88
|
# File 'foobara-typescript-remote-command-generator-1.1.1/src/remote_generator/services/command_result_generator.rb', line 86
def aggregate?
serializers&.any? { |s| s == "Foobara::CommandConnectors::Serializers::AggregateSerializer" }
end
|
#association_depth ⇒ Object
#atom? ⇒ Boolean
82
83
84
|
# File 'foobara-typescript-remote-command-generator-1.1.1/src/remote_generator/services/command_result_generator.rb', line 82
def atom?
serializers&.any? { |s| s == "Foobara::CommandConnectors::Serializers::AtomicSerializer" }
end
|
#dependencies ⇒ Object
100
101
102
|
# File 'foobara-typescript-remote-command-generator-1.1.1/src/remote_generator/services/command_result_generator.rb', line 100
def dependencies
model_generators + type_generators
end
|
#model_generators(type = result_type, initial = true) ⇒ 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
|
# File 'foobara-typescript-remote-command-generator-1.1.1/src/remote_generator/services/command_result_generator.rb', line 21
def model_generators(type = result_type, initial = true)
return [] if type.nil?
if 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
end
|
#result_type ⇒ Object
9
10
11
|
# File 'foobara-typescript-remote-command-generator-1.1.1/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 'foobara-typescript-remote-command-generator-1.1.1/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 'foobara-typescript-remote-command-generator-1.1.1/src/remote_generator/services/command_result_generator.rb', line 17
def template_path
"Command/Result.ts.erb"
end
|
#type_generators ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'foobara-typescript-remote-command-generator-1.1.1/src/remote_generator/services/command_result_generator.rb', line 66
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
|