Class: Foobara::Manifest::Attributes

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

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary

Attributes inherited from BaseManifest

#path, #root_manifest

Instance Method Summary collapse

Methods inherited from TypeDeclaration

#allows_nil?, #array?, #attribute?, #attribute_name, #attributes?, #custom?, #default, #detached_entity?, #entity?, #model?, new, #parent_attributes, #sensitive?, #to_detached_entity, #to_entity, #to_model, #to_type, #type_declaration_manifest

Methods inherited from BaseManifest

#==, #[], category_to_manifest_class, #domain, #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, #relevant_manifest, #respond_to_missing?, #scoped_category

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



22
23
24
25
26
27
28
29
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/attributes.rb', line 22

def attribute_declarations
  element_type_declarations.keys.to_h do |attribute_name|
    [
      attribute_name.to_sym,
      TypeDeclaration.new(root_manifest, [*path, :element_type_declarations, attribute_name])
    ]
  end
end

#attribute_namesObject



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

def attribute_names
  attribute_declarations.keys.map(&:to_s)
end

#default_for(attribute_name) ⇒ Object



18
19
20
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/attributes.rb', line 18

def default_for(attribute_name)
  DataPath.value_at([:defaults, attribute_name], attributes_manifest)
end

#empty?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/attributes.rb', line 31

def empty?
  attribute_declarations.empty?
end

#required?(attribute_name) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/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