Class: Foobara::Manifest::Attributes
Constant Summary
TruncatedInspect::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseManifest
#manifest_path, #root_manifest
Instance Method Summary
collapse
#allows_nil?, #array?, #associative_array?, #attribute?, #attribute_name, #attributes?, #custom?, #default, #detached_entity?, #entity?, #model?, new, #parent_attributes, #primitive?, #reference?, #sensitive, #sensitive?, #sensitive_exposed, #to_detached_entity, #to_entity, #to_model, #to_type, #tuple?, #type, #type_declaration_manifest, #type_symbol
#==, #[], category_to_manifest_class, #domain, #domain_reference, #eql?, #find_type, #global_domain, #global_organization, #hash, #initialize, #key?, #method_missing, optional_key, #optional_key?, optional_key_defaults, optional_keys, #organization, #parent, #parent_category, #parent_name, #path, #relevant_manifest, #respond_to_missing?, #scoped_category, #symbol_path
#inspect, truncating
Instance Method Details
#attribute_declarations ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'projects/manifest/src/attributes.rb', line 26
def attribute_declarations
element_type_declarations.keys.to_h do |attribute_name|
[
attribute_name.to_sym,
TypeDeclaration.new(root_manifest, [*manifest_path, :element_type_declarations, attribute_name])
]
end
end
|
#attribute_names ⇒ Object
39
40
41
|
# File 'projects/manifest/src/attributes.rb', line 39
def attribute_names
attribute_declarations.keys.map(&:to_s)
end
|
#default_for(attribute_name) ⇒ Object
18
19
20
|
# File 'projects/manifest/src/attributes.rb', line 18
def default_for(attribute_name)
DataPath.value_at([:defaults, attribute_name], attributes_manifest)
end
|
#empty? ⇒ Boolean
35
36
37
|
# File 'projects/manifest/src/attributes.rb', line 35
def empty?
attribute_declarations.empty?
end
|
#has_attribute_declarations? ⇒ Boolean
22
23
24
|
# File 'projects/manifest/src/attributes.rb', line 22
def has_attribute_declarations?
!element_type_declarations.nil?
end
|
#required?(attribute_name) ⇒ Boolean
10
11
12
13
14
15
16
|
# File 'projects/manifest/src/attributes.rb', line 10
def required?(attribute_name)
required = DataPath.value_at(:required, attributes_manifest)
if required
required.include?(attribute_name.to_sym) || required.include?(attribute_name.to_s)
end
end
|