Class: Foobara::Manifest::RootManifest
Constant Summary
TruncatedInspect::MAX_LENGTH
Instance Attribute Summary collapse
Attributes inherited from BaseManifest
#path
Instance Method Summary
collapse
#inspect, truncating
#==, #[], category_to_manifest_class, #domain, #eql?, #find_type, #global_domain, #global_organization, #hash, #key?, #method_missing, optional_key, #optional_key?, optional_key_defaults, optional_keys, #organization, #parent, #parent_category, #parent_name, #relevant_manifest, #respond_to_missing?, #scoped_category
Constructor Details
#initialize(root_manifest) ⇒ RootManifest
Returns a new instance of RootManifest.
8
9
10
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 8
def initialize(root_manifest)
super(root_manifest, [])
end
|
Instance Attribute Details
#root_manifest ⇒ Object
Returns the value of attribute root_manifest.
6
7
8
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 6
def root_manifest
@root_manifest
end
|
Instance Method Details
#command_by_name(name) ⇒ Object
76
77
78
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 76
def command_by_name(name)
Command.new(root_manifest, [:command, name])
end
|
#commands ⇒ Object
24
25
26
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 24
def commands
organizations.map(&:commands).flatten
end
|
#contains?(reference, category) ⇒ Boolean
TODO: this isn’t quite right. If the thing is there but is nil or false, this should be truthy.
89
90
91
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 89
def contains?(reference, category)
DataPath.value_at([category, reference], root_manifest)
end
|
#detached_entity_by_name(name) ⇒ Object
48
49
50
51
52
53
54
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 48
def detached_entity_by_name(name)
type = type_by_name(name)
raise "#{name} is not a detached entity" unless type.detached_entity?
type
end
|
#domain_by_name(name) ⇒ Object
80
81
82
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 80
def domain_by_name(name)
Domain.new(root_manifest, [:domain, name])
end
|
#domains ⇒ Object
18
19
20
21
22
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 18
def domains
@domains ||= DataPath.value_at(:domain, root_manifest).keys.map do |reference|
Domain.new(root_manifest, [:domain, reference])
end
end
|
#entities ⇒ Object
34
35
36
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 34
def entities
organizations.map(&:entities).flatten
end
|
#entity_by_name(name) ⇒ Object
56
57
58
59
60
61
62
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 56
def entity_by_name(name)
type = type_by_name(name)
raise "#{name} is not an entity" unless type.entity?
type
end
|
#errors ⇒ Object
42
43
44
45
46
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 42
def errors
@errors ||= DataPath.value_at(:error, root_manifest).keys.map do |reference|
Error.new(root_manifest, [:error, reference])
end
end
|
#lookup(reference) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 104
def lookup(reference)
prioritized_categories = %i[command type error domain organization processor processor_class]
prioritized_categories.each do |category|
path = [category, reference]
raw_manifest = DataPath.value_at(path, root_manifest)
if raw_manifest
return self.class.category_to_manifest_class(category).new(root_manifest, path)
end
end
nil
end
|
#lookup_path(category, reference) ⇒ Object
93
94
95
96
97
98
99
100
101
102
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 93
def lookup_path(category, reference)
path = [category, reference]
raw_manifest = DataPath.value_at(path, root_manifest)
if raw_manifest
return self.class.category_to_manifest_class(category).new(root_manifest, path)
end
nil
end
|
#model_by_name(name) ⇒ Object
64
65
66
67
68
69
70
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 64
def model_by_name(name)
type = type_by_name(name)
raise "#{name} is not a model" unless type.model?
type
end
|
#models ⇒ Object
38
39
40
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 38
def models
organizations.map(&:models).flatten
end
|
#organization_by_name(name) ⇒ Object
84
85
86
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 84
def organization_by_name(name)
Organization.new(root_manifest, [:organization, name])
end
|
#organizations ⇒ Object
12
13
14
15
16
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 12
def organizations
@organizations ||= DataPath.value_at(:organization, root_manifest).keys.map do |reference|
Organization.new(root_manifest, [:organization, reference])
end
end
|
#type_by_name(name) ⇒ Object
72
73
74
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 72
def type_by_name(name)
Type.new(root_manifest, [:type, name])
end
|
#types ⇒ Object
28
29
30
31
32
|
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/root_manifest.rb', line 28
def types
@types ||= DataPath.value_at(:type, root_manifest).keys.map do |reference|
Type.new(root_manifest, [:type, reference])
end
end
|