Module: Jinx::PropertyCharacteristics
- Included in:
- Property
- Defined in:
- lib/jinx/metadata/property_characteristics.rb
Overview
The PropertyCharacteristics mix-in queries the Property flags and features.
Instance Method Summary collapse
-
#bidirectional? ⇒ Boolean
Whether this property has an inverse.
-
#bidirectional_java_association? ⇒ Boolean
Whether this is a Java attribute which has a Java inverse.
-
#collection? ⇒ Boolean
Whether the subject attribute return type is a collection.
-
#dependent? ⇒ Boolean
Returns whether the subject attribute is a dependent on a parent.
-
#derived? ⇒ Boolean
An attribute is derived if the attribute value is set by setting another attribute, e.g.
-
#disjoint? ⇒ Boolean
Whether this is a dependent attribute which has exactly one owner value chosen from several owner attributes.
-
#domain? ⇒ Boolean
Whether the subject attribute returns a domain object or collection of domain objects.
-
#independent? ⇒ Boolean
An independent attribute is a reference to one or more non-dependent Resource objects.
-
#java_property? ⇒ Boolean
Whether the subject attribute encapsulates a Java attribute.
-
#mandatory? ⇒ Boolean
Returns whether the subject attribute must have a value when it is saved.
-
#many_to_many? ⇒ Boolean
Whether this attribute is a collection with a collection inverse.
-
#nondomain? ⇒ Boolean
Whether the subject attribute is not a domain object attribute.
-
#owner? ⇒ Boolean
Whether the subject attribute is a dependency owner.
-
#restriction?(other) ⇒ Boolean
protected
Whether the other attribute restricts this attribute.
-
#unidirectional? ⇒ Boolean
An attribute is unidirectional if both of the following is true: * there is no distinct #inverse attribute * the attribute is not a #dependent? with more than one owner.
-
#unidirectional_java_dependent? ⇒ Boolean
Whether this attribute is a dependent which does not have a Java inverse owner attribute.
Instance Method Details
#bidirectional? ⇒ Boolean
21 22 23 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 21 def bidirectional? !!@inv_prop end |
#bidirectional_java_association? ⇒ Boolean
102 103 104 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 102 def bidirectional_java_association? inverse and java_property? and inverse_property.java_property? end |
#collection? ⇒ Boolean
42 43 44 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 42 def collection? @flags.include?(:collection) end |
#dependent? ⇒ Boolean
Returns whether the subject attribute is a dependent on a parent. See the Jinx configuration documentation for a dependency description.
50 51 52 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 50 def dependent? @flags.include?(:dependent) end |
#derived? ⇒ Boolean
An attribute is derived if the attribute value is set by setting another attribute, e.g. if this attribute is the inverse of a dependent owner attribute.
65 66 67 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 65 def derived? dependent? and !!inverse end |
#disjoint? ⇒ Boolean
91 92 93 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 91 def disjoint? @flags.include?(:disjoint) end |
#domain? ⇒ Boolean
31 32 33 34 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 31 def domain? # the type must be a Ruby class rather than a Java Class, and include the Domain mix-in Class === type and type < Resource end |
#independent? ⇒ Boolean
An independent attribute is a reference to one or more non-dependent Resource objects. An #owner? attribute is independent.
73 74 75 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 73 def independent? domain? and not dependent? end |
#java_property? ⇒ Boolean
26 27 28 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 26 def java_property? JavaProperty === self end |
#mandatory? ⇒ Boolean
Returns whether the subject attribute must have a value when it is saved
57 58 59 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 57 def mandatory? @declarer.mandatory_attributes.include?(attribute) end |
#many_to_many? ⇒ Boolean
78 79 80 81 82 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 78 def many_to_many? return false unless collection? inv_prop = inverse_property inv_prop and inv_prop.collection? end |
#nondomain? ⇒ Boolean
37 38 39 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 37 def nondomain? not domain? end |
#owner? ⇒ Boolean
85 86 87 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 85 def owner? @flags.include?(:owner) end |
#restriction?(other) ⇒ Boolean (protected)
110 111 112 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 110 def restriction?(other) @restrictions and @restrictions.include?(other) end |
#unidirectional? ⇒ Boolean
An attribute is unidirectional if both of the following is true:
-
there is no distinct #inverse attribute
-
the attribute is not a #dependent? with more than one owner
16 17 18 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 16 def unidirectional? inverse.nil? and not (dependent? and type.owner_attributes.size > 1) end |
#unidirectional_java_dependent? ⇒ Boolean
97 98 99 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 97 def unidirectional_java_dependent? dependent? and java_property? and not bidirectional_java_association? end |