Class: Foobara::Manifest::Attributes

Inherits:
TypeDeclaration show all
Defined in:
foobara-0.5.8/projects/manifest/src/attributes.rb

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary

Attributes inherited from BaseManifest

#manifest_path, #root_manifest

Instance Method Summary collapse

Methods inherited from TypeDeclaration

#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

Methods inherited from BaseManifest

#==, #[], 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

Methods included from TruncatedInspect

#inspect, truncating

Constructor Details

This class inherits a constructor from Foobara::Manifest::BaseManifest

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Foobara::Manifest::BaseManifest

Instance Method Details

#attribute_declarationsObject



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_namesObject



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

Returns:

  • (Boolean)


35
36
37
# File 'projects/manifest/src/attributes.rb', line 35

def empty?
  attribute_declarations.empty?
end

#has_attribute_declarations?Boolean

Returns:

  • (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

Returns:

  • (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