forked from OpenNeo/impress
24 lines
698 B
Ruby
24 lines
698 B
Ruby
class ParentSwfAssetRelationship < ActiveRecord::Base
|
|
set_table_name 'parents_swf_assets'
|
|
|
|
belongs_to :item, :foreign_key => 'parent_id'
|
|
|
|
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)
|
|
self.parent_id = replacement.id
|
|
end
|
|
|
|
def pet_state
|
|
PetState.find(parent_id)
|
|
end
|
|
|
|
def pet_state=(replacement)
|
|
self.parent_id = replacement.id
|
|
end
|
|
end
|