Class: ActiveFacts::Metamodel::PresenceConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/activefacts/vocabulary/metamodel.rb,
lib/activefacts/vocabulary/extensions.rb

Instance Method Summary collapse

Instance Method Details

#describeObject



695
696
697
698
699
# File 'lib/activefacts/vocabulary/extensions.rb', line 695

def describe
  min = min_frequency
  max = max_frequency
  role_sequence.describe + " occurs " + frequency + " time#{(min&&min>1)||(max&&max>1) ? 's' : ''}"
end

#frequencyObject



685
686
687
688
689
690
691
692
693
# File 'lib/activefacts/vocabulary/extensions.rb', line 685

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