1
0
Fork 0
forked from OpenNeo/impress
impress/app/models/swf_asset_parent.rb

13 lines
412 B
Ruby
Raw Normal View History

module SwfAssetParent
def swf_assets
2010-05-20 16:56:08 -07:00
rels = ParentSwfAssetRelationship.arel_table
type = self.class::SwfAssetType
ids = ParentSwfAssetRelationship.
where(rels[:parent_id].eq(id).and(rels[:swf_asset_type].eq(type))).
select(rels[:swf_asset_id]).
all.map(&:swf_asset_id)
2010-05-20 16:56:08 -07:00
assets = SwfAsset.arel_table
SwfAsset.where(assets[:id].in(ids).and(assets[:type].eq(type)))
end
end