Sha256: 34ba3caa6ab7f6288aa59c71cbfd7288cbb1465ffadf61210dd932ab2c48a4e2
Contents?: true
Size: 714 Bytes
Versions: 6
Compression:
Stored size: 714 Bytes
Contents
module ActiveMocker module Mock class SingleRelation attr_reader :item def initialize(item, child_self:, foreign_key:, foreign_id:) @item = item assign_associations(child_self, item) if item.class <= Base end def assign_associations(child_self, item) [*item.class._find_associations_by_class(child_self.class.send('mocked_class'))].each do |type, relations| relations.each do |relation| if item.send(relation).class <= Collection item.send(relation) << child_self else item.send(:write_association, relation, child_self) end end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems