Module: CaTissue::Annotation::Metadata

Includes:
CaRuby::Metadata
Defined in:
lib/catissue/annotation/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#annotation_moduleModule

Returns the module which imported this annotation class.

Returns:

  • (Module)

    the module which imported this annotation class



18
19
20
# File 'lib/catissue/annotation/metadata.rb', line 18

def annotation_module
  @annotation_module
end

#container_idIntger? (readonly)

Returns the container id, or nil if this is not a primary annotation.

Returns:

  • (Intger, nil)

    the container id, or nil if this is not a primary annotation



15
16
17
# File 'lib/catissue/annotation/metadata.rb', line 15

def container_id
  @container_id
end

#entity_idInteger? (readonly)

Returns the annotation class designator that is used by caTissue to persist primary annotation objects, or nil if this is not a primary annotation.

Returns:

  • (Integer, nil)

    the annotation class designator that is used by caTissue to persist primary annotation objects, or nil if this is not a primary annotation



12
13
14
# File 'lib/catissue/annotation/metadata.rb', line 12

def entity_id
  @entity_id
end

Instance Method Details

#add_annotation_metadata(mod) ⇒ Object

Adds metadata to this annotation class. This method is intended for the sole use of the Annotation Importer.

Parameters:

  • mod (Module)

    the module which scopes this annotation



45
46
47
48
49
50
51
52
# File 'lib/catissue/annotation/metadata.rb', line 45

def (mod)
  logger.debug { "Adding #{mod.qp} annotation #{qp} metadata..." }
  # Set the primary key.
  property :identifier, :primary_key
  self.annotation_module = mod
  infer_entity_id
  logger.debug { "#{mod.qp} annotation #{qp} metadata is complete." }
end

#annotation_attributesSymbol

Returns the domain attributes which include CaTissue::Annotation.

Returns:



55
56
57
# File 'lib/catissue/annotation/metadata.rb', line 55

def annotation_attributes
  @ann_attrs ||= domain_attributes.compose { |prop| prop.type < Annotation }
end

#annotation_hierarchy<Class>

Returns the annotation class hierarchy, including this class.

Returns:

  • (<Class>)

    the annotation class hierarchy, including this class



21
22
23
# File 'lib/catissue/annotation/metadata.rb', line 21

def annotation_hierarchy
  class_hierarchy.filter { |klass| klass < Annotation }
end

#hook_classMetadata Also known as: hook

Returns the annotated domain object class.

Returns:

  • (Metadata)

    the annotated domain object class



82
83
84
# File 'lib/catissue/annotation/metadata.rb', line 82

def hook_class
  proxy.hook
end

#hook_proxy_attributeSymbol?

Returns the hook proxy class attribute which references this annotation class, or nil if this is not a primary annotation class.

Returns:

  • (Symbol, nil)

    the hook proxy class attribute which references this annotation class, or nil if this is not a primary annotation class



102
103
104
105
# File 'lib/catissue/annotation/metadata.rb', line 102

def hook_proxy_attribute
  # The hook => primary attribute symbol is the same as the proxy => primary attribute symbol.
  @pxy_prop.inverse if @pxy_prop
end

#loadable_attributesArray

Filters CaRuby::Propertied.loadable_attributes to exclude all references, since annotation lazy-loading is not supported.

Returns:

  • (Array)

    an empty array



63
64
65
# File 'lib/catissue/annotation/metadata.rb', line 63

def loadable_attributes
  Array::EMPTY_ARRAY
end

#primary?Boolean

Returns whether this annotation class references a hook proxy.

Returns:

  • (Boolean)

    whether this annotation class references a hook proxy



26
27
28
# File 'lib/catissue/annotation/metadata.rb', line 26

def primary?
  @is_primary
end

#proxy_attributeSymbol?

Returns the attribute symbol which references the hook proxy, or nil if this is not a primary annotation class.

Returns:

  • (Symbol, nil)

    the attribute symbol which references the hook proxy, or nil if this is not a primary annotation class



96
97
98
# File 'lib/catissue/annotation/metadata.rb', line 96

def proxy_attribute
  @pxy_prop.to_sym if @pxy_prop
end

#proxy_classProxyClass Also known as: proxy

Returns the annotation proxy class.

Returns:



75
76
77
# File 'lib/catissue/annotation/metadata.rb', line 75

def proxy_class
  annotation_module.proxy
end

#proxy_propertyJinx::Property?

Returns the attribute metadata which references the hook proxy, or nil if this is not a primary annotation class.

Returns:

  • (Jinx::Property, nil)

    the attribute metadata which references the hook proxy, or nil if this is not a primary annotation class



90
91
92
# File 'lib/catissue/annotation/metadata.rb', line 90

def proxy_property
  @pxy_prop
end

#save_dependent_attributes(annotation) ⇒ Object

Saves the annotations referenced by the given annotation.

Parameters:

  • annotation (Annotation)

    the subject annotation



70
71
72
# File 'lib/catissue/annotation/metadata.rb', line 70

def save_dependent_attributes(annotation)
  dependent_attributes.each { |pa| save_dependent_attribute(annotation, pa) }
end

#secondary?Boolean

Returns whether this annotation refers to a #primary? annotation.

Returns:

  • (Boolean)

    whether this annotation refers to a #primary? annotation



31
32
33
34
# File 'lib/catissue/annotation/metadata.rb', line 31

def secondary?
  ref = domain_attributes. { |prop| prop.type < Annotation and prop.type.primary? }
  not ref.nil?
end

#tertiary?Boolean

Returns whether this annotation is neither a #primary? nor a #secondary? annotation.

Returns:



37
38
39
# File 'lib/catissue/annotation/metadata.rb', line 37

def tertiary?
  not (primary? or secondary?)
end

#toxic_attributesArray

Returns an empty array, since no annotation reference is lazy-loaded by caTissue.

Returns:

  • (Array)

    an empty array, since no annotation reference is lazy-loaded by caTissue.



108
109
110
# File 'lib/catissue/annotation/metadata.rb', line 108

def toxic_attributes
  Array::EMPTY_ARRAY
end