2010-05-19 16:17:33 -07:00
|
|
|
module SwfAssetParent
|
|
|
|
def swf_assets
|
2010-05-20 16:56:08 -07:00
|
|
|
rels = ParentSwfAssetRelationship.arel_table
|
2010-05-19 16:17:33 -07:00
|
|
|
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
|
2010-05-20 18:23:24 -07:00
|
|
|
SwfAsset.where(assets[:id].in(ids).and(assets[:type].eq(type)))
|
2010-05-19 16:17:33 -07:00
|
|
|
end
|
|
|
|
end
|