Class: Foobara::Manifest::Attributes

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

Instance Attribute Summary

Attributes inherited from TypeDeclaration

#base_type, #declaration_data, #is_absolutified, #is_deep_duped, #is_duped, #is_strict, #reference_checked, #type

Instance Method Summary collapse

Methods inherited from TypeDeclaration

#[], #[]=, #all_symbolizable_keys?, #array?, #assign, #class?, #clone, #clone_from_part, #delete, #except, #handle_symbolic_declaration, #hash?, #initialize, #key?, #proc?, #reference?, #size, #slice, #symbolize_keys!, #to_proc

Constructor Details

This class inherits a constructor from Foobara::TypeDeclaration

Instance Method Details

#attribute_declarationsObject



26
27
28
29
30
31
32
33
# File 'foobara-0.1.7/projects/manifest/src/foobara/manifest/attributes.rb', line 26

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



39
40
41
# File 'foobara-0.1.7/projects/manifest/src/foobara/manifest/attributes.rb', line 39

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

#default_for(attribute_name) ⇒ Object



18
19
20
# File 'foobara-0.1.7/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)


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

def empty?
  attribute_declarations.empty?
end

#has_attribute_declarations?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'foobara-0.1.7/projects/manifest/src/foobara/manifest/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 'foobara-0.1.7/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