Module: Polymorpheus::Interface::ValidatesPolymorph

Defined in:
lib/polymorpheus/interface/validates_polymorph.rb

Instance Method Summary collapse

Instance Method Details

#validates_polymorph(polymorphic_api) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/polymorpheus/interface/validates_polymorph.rb', line 4

def validates_polymorph(polymorphic_api)
  validate Proc.new {
    unless polymorpheus.active_association
      association_names = polymorpheus.associations.map(&:name)
      errors.add(:base, "You must specify exactly one of the following: "\
                        "{#{association_names.join(', ')}}")
    end
  }
end