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



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



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



92
93
94
# File 'lib/jinx/metadata/property_characteristics.rb', line 92

def disjoint?
  @flags.include?(:disjoint)
end

#domain?Boolean



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



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



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



38
39
40
# File 'lib/jinx/metadata/property_characteristics.rb', line 38

def nondomain?
  not domain?
end

#owner?Boolean



86
87
88
# File 'lib/jinx/metadata/property_characteristics.rb', line 86

def owner?
  @flags.include?(:owner)
end

#restriction?(other) ⇒ Boolean (protected)



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



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