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 a 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
Returns whether this property has an inverse.
21 22 23 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 21 def bidirectional? !!@inv_prop end |
#bidirectional_java_association? ⇒ Boolean
Returns whether this is a Java attribute which has a Java inverse.
103 104 105 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 103 def bidirectional_java_association? inverse and java_property? and inverse_property.java_property? end |
#collection? ⇒ Boolean
Returns whether the subject attribute return type is a collection.
43 44 45 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 43 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.
51 52 53 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 51 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.
66 67 68 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 66 def derived? dependent? and !!inverse end |
#disjoint? ⇒ Boolean
Returns whether this is a dependent attribute which has exactly one owner value chosen from several owner attributes.
92 93 94 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 92 def disjoint? @flags.include?(:disjoint) end |
#domain? ⇒ Boolean
Returns whether the subject attribute returns a domain object or a collection of domain objects.
32 33 34 35 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 32 def domain? # the type must be a Ruby class that extends the {Metadata} mix-in Class === type and type < Resource and type.introspected? end |
#independent? ⇒ Boolean
An independent attribute is a reference to one or more non-dependent Resource objects. An #owner? attribute is independent.
74 75 76 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 74 def independent? domain? and not dependent? end |
#java_property? ⇒ Boolean
Returns whether the subject attribute encapsulates a Java attribute.
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
58 59 60 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 58 def mandatory? @declarer.mandatory_attributes.include?(attribute) end |
#many_to_many? ⇒ Boolean
Returns whether this attribute is a collection with a collection inverse.
79 80 81 82 83 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 79 def many_to_many? return false unless collection? inv_prop = inverse_property inv_prop and inv_prop.collection? end |
#nondomain? ⇒ Boolean
Returns whether the subject attribute is not a domain object attribute.
38 39 40 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 38 def nondomain? not domain? end |
#owner? ⇒ Boolean
Returns whether the subject attribute is a dependency owner.
86 87 88 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 86 def owner? @flags.include?(:owner) end |
#restriction?(other) ⇒ Boolean (protected)
Returns whether the other attribute restricts this attribute.
111 112 113 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 111 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
Returns whether this attribute is a dependent which does not have a Java inverse owner attribute.
98 99 100 |
# File 'lib/jinx/metadata/property_characteristics.rb', line 98 def unidirectional_java_dependent? dependent? and java_property? and not bidirectional_java_association? end |