Wondering if there is an easy way to determine dynamically if a model's association is a "has_one" or "has_many" relationship (i.e. is this an association to one object or many).
I'm using MongoMapper, so I am able to check if a class klass has an associated model assoc with a one or many relationship via
klass.associations[:assoc].is_a? MongoMapper::Plugins::Associations::OneAssociation
klass.associations[:assoc].is_a? MongoMapper::Plugins::Associations::ManyAssociation
but this seems rather clunky, and isn't generic (i.e. won't work for ActiveRecord associations as well). I'd also like to avoid loading any objects, so I'm pretty sure that instance.assoc.is_a? Array is out too.
Any ideas?