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

25 lines
698 B
Ruby
Raw Normal View History

class ParentSwfAssetRelationship < ActiveRecord::Base
set_table_name 'parents_swf_assets'
2011-01-27 13:35:46 -08:00
belongs_to :item, :foreign_key => 'parent_id'
2010-10-10 19:18:42 -07:00
belongs_to :biology_asset, :class_name => 'SwfAsset', :foreign_key => 'swf_asset_id', :conditions => {:type => 'biology'}
belongs_to :object_asset, :class_name => 'SwfAsset', :foreign_key => 'swf_asset_id', :conditions => {:type => 'object'}
def swf_asset
self.swf_asset_type == 'biology' ? self.biology_asset : self.object_asset
end
def item=(replacement)
2010-05-16 17:45:30 -07:00
self.parent_id = replacement.id
end
def pet_state
2011-01-27 13:35:46 -08:00
PetState.find(parent_id)
2010-05-16 17:45:30 -07:00
end
def pet_state=(replacement)
2010-05-16 17:45:30 -07:00
self.parent_id = replacement.id
end
end