Class: Foobara::Manifest::Model

Inherits:
Type show all
Defined in:
foobara-0.0.110/projects/manifest/src/foobara/manifest/model.rb

Direct Known Subclasses

DetachedEntity

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 Type

#base_type, #builtin?, #custom?, #detached_entity?, #entity?, #extends_symbol?, #full_type_name, #model?, new, #target_class, #to_type_declaration_from_declaration_data, #type_manifest, #type_name, #types_depended_on

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_namesObject



14
15
16
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/model.rb', line 14

def attribute_names
  attributes_type.attribute_names
end

#attributes_typeObject



10
11
12
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/model.rb', line 10

def attributes_type
  Attributes.new(root_manifest, [*path, :attributes_type])
end

#full_model_nameObject



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

def full_model_name
  scoped_full_name
end

#has_associations?(type = attributes_type) ⇒ Boolean

TODO: rename

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'foobara-0.0.110/projects/manifest/src/foobara/manifest/model.rb', line 23

def has_associations?(type = attributes_type)
  case type
  when Entity
    true
  when Model
    has_associations?(type.attributes_type)
  when Attributes
    type.attribute_declarations.values.any? do |attribute_declaration|
      has_associations?(attribute_declaration)
    end
  when Array
    has_associations?(type.element_type)
  when TypeDeclaration
    has_associations?(type.to_type)
  when Type
    type.entity?
  else
    # :nocov:
    raise "not sure how to proceed with #{type}"
    # :nocov:
  end
end