Module: Traitor::ConflictCheck
- Defined in:
- lib/traitor/conflict_check.rb
Defined Under Namespace
Classes: TraitConflict
Class Method Summary collapse
Class Method Details
.check(host_class) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/traitor/conflict_check.rb', line 6 def check(host_class) conflicts = [] traits = host_class.traits traits.each do |t| traits.reject { |other| other == t }.each do |other| t.trait_methods.each do |m| conflicts << m if other.implements?(m) end end end conflicts.delete_if do |c| host_class.instance_methods(false).include?(c) end return false if conflicts.empty? output = "Conflicting methods: #{conflicts.uniq.map {|c| "##{c}"}.join(', ')}" raise TraitConflict, output end |