Module: Portable::Util::Uniqueness
- Included in:
- Data::Provider, Document
- Defined in:
- lib/portable/util/uniqueness.rb
Overview
Mixes in helpers for asserting uniqueness across collections
Defined Under Namespace
Classes: DuplicateNameError
Instance Method Summary collapse
Instance Method Details
#assert_no_duplicate_names(array) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/portable/util/uniqueness.rb', line 16 def assert_no_duplicate_names(array) names = array.map { |a| a.name.downcase } return if names.uniq.length == array.length raise DuplicateNameError, "cannot contain duplicate names (case insensitive): #{names}" end |