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

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