2010-05-16 12:01:38 -07:00
|
|
|
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
|
2010-05-16 12:01:38 -07:00
|
|
|
|
|
|
|
def item=(replacement)
|
2010-05-16 17:45:30 -07:00
|
|
|
self.parent_id = replacement.id
|
|
|
|
end
|
|
|
|
|
2010-05-20 18:11:08 -07:00
|
|
|
def pet_state
|
2011-01-27 13:35:46 -08:00
|
|
|
PetState.find(parent_id)
|
2010-05-16 17:45:30 -07:00
|
|
|
end
|
|
|
|
|
2010-05-20 18:11:08 -07:00
|
|
|
def pet_state=(replacement)
|
2010-05-16 17:45:30 -07:00
|
|
|
self.parent_id = replacement.id
|
2010-05-16 12:01:38 -07:00
|
|
|
end
|
|
|
|
end
|