Class: ActiveFacts::Metamodel::PresenceConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- ActiveFacts::Metamodel::PresenceConstraint
- Defined in:
- lib/activefacts/metamodel/metamodel.rb,
lib/activefacts/metamodel/extensions.rb
Instance Method Summary collapse
Instance Method Details
#all_constrained_role ⇒ Object
1175 1176 1177 |
# File 'lib/activefacts/metamodel/extensions.rb', line 1175 def all_constrained_role role_sequence.all_role_ref.map(&:role) end |
#covers_role(role) ⇒ Object
1171 1172 1173 |
# File 'lib/activefacts/metamodel/extensions.rb', line 1171 def covers_role role role_sequence.all_role_ref.map(&:role).include?(role) end |
#describe ⇒ Object
1165 1166 1167 1168 1169 |
# File 'lib/activefacts/metamodel/extensions.rb', line 1165 def describe min = min_frequency max = max_frequency 'PresenceConstraint over '+role_sequence.describe + " occurs " + frequency + " time#{(min&&min>1)||(max&&max>1) ? 's' : ''}" end |
#frequency ⇒ Object
1155 1156 1157 1158 1159 1160 1161 1162 1163 |
# File 'lib/activefacts/metamodel/extensions.rb', line 1155 def frequency min = min_frequency max = max_frequency [ ((min && min > 0 && min != max) ? "at least #{min == 1 ? "one" : min.to_s}" : nil), ((max && min != max) ? "at most #{max == 1 ? "one" : max.to_s}" : nil), ((max && min == max) ? "#{max == 1 ? "one" : "exactly "+max.to_s}" : nil) ].compact * " and " end |