Module: CaTissue::Annotation::Metadata
- Includes:
- CaRuby::Metadata
- Defined in:
- lib/catissue/annotation/metadata.rb
Instance Attribute Summary collapse
-
#annotation_module ⇒ Module
readonly
The module which imported this annotation class.
-
#container_id ⇒ Intger?
readonly
The container id, or nil if this is not a primary annotation.
-
#entity_id ⇒ Integer?
readonly
The annotation class designator that is used by caTissue to persist primary annotation objects, or nil if this is not a primary annotation.
Instance Method Summary collapse
-
#add_annotation_metadata(mod) ⇒ Object
Adds metadata to this annotation class.
-
#annotation_attributes ⇒ Symbol
The domain attributes which include CaTissue::Annotation.
-
#annotation_hierarchy ⇒ <Class>
The annotation class hierarchy, including this class.
-
#hook_class ⇒ Metadata
(also: #hook)
The annotated domain object class.
-
#hook_proxy_attribute ⇒ Symbol?
The hook proxy class attribute which references this annotation class, or nil if this is not a primary annotation class.
-
#loadable_attributes ⇒ Array
Filters
CaRuby::Propertied.loadable_attributes
to exclude all references, since annotation lazy-loading is not supported. -
#primary? ⇒ Boolean
Whether this annotation class references a hook proxy.
-
#proxy_attribute ⇒ Symbol?
The attribute symbol which references the hook proxy, or nil if this is not a primary annotation class.
-
#proxy_class ⇒ ProxyClass
(also: #proxy)
The annotation proxy class.
-
#proxy_property ⇒ Jinx::Property?
The attribute metadata which references the hook proxy, or nil if this is not a primary annotation class.
-
#save_dependent_attributes(annotation) ⇒ Object
Saves the annotations referenced by the given annotation.
-
#secondary? ⇒ Boolean
Whether this annotation refers to a #primary? annotation.
-
#tertiary? ⇒ Boolean
Whether this annotation is neither a #primary? nor a #secondary? annotation.
-
#toxic_attributes ⇒ Array
An empty array, since no annotation reference is lazy-loaded by caTissue.
Instance Attribute Details
#annotation_module ⇒ Module
Returns 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_id ⇒ Intger? (readonly)
Returns 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_id ⇒ Integer? (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.
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.
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_attributes ⇒ Symbol
Returns the domain attributes which include CaTissue::Annotation.
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.
21 22 23 |
# File 'lib/catissue/annotation/metadata.rb', line 21 def annotation_hierarchy class_hierarchy.filter { |klass| klass < Annotation } end |
#hook_class ⇒ Metadata Also known as: hook
Returns the annotated domain object class.
82 83 84 |
# File 'lib/catissue/annotation/metadata.rb', line 82 def hook_class proxy.hook end |
#hook_proxy_attribute ⇒ Symbol?
Returns 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_attributes ⇒ Array
Filters CaRuby::Propertied.loadable_attributes
to exclude all references, since annotation lazy-loading is not supported.
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.
26 27 28 |
# File 'lib/catissue/annotation/metadata.rb', line 26 def primary? @is_primary end |
#proxy_attribute ⇒ Symbol?
Returns 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_class ⇒ ProxyClass Also known as: proxy
Returns the annotation proxy class.
75 76 77 |
# File 'lib/catissue/annotation/metadata.rb', line 75 def proxy_class annotation_module.proxy end |
#proxy_property ⇒ Jinx::Property?
Returns 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.
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.
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.
37 38 39 |
# File 'lib/catissue/annotation/metadata.rb', line 37 def tertiary? not (primary? or secondary?) end |
#toxic_attributes ⇒ Array
Returns 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 |