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



380
381
382
# File 'lib/activefacts/vocabulary/extensions.rb', line 380

def describe
  role_sequence.describe + " occurs " + frequency + " time"
end

#frequencyObject



370
371
372
373
374
375
376
377
378
# File 'lib/activefacts/vocabulary/extensions.rb', line 370

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" : max.to_s}" : nil)
  ].compact * " and"
end