2010-05-16 12:01:38 -07:00
|
|
|
class SwfAsset < ActiveRecord::Base
|
|
|
|
set_inheritance_column 'inheritance_type'
|
2010-05-20 16:04:56 -07:00
|
|
|
|
|
|
|
delegate :depth, :to => :zone
|
|
|
|
|
2010-06-08 15:26:42 -07:00
|
|
|
scope :fitting_body_id, lambda { |body_id|
|
|
|
|
where(arel_table[:body_id].in([body_id, 0]))
|
|
|
|
}
|
|
|
|
|
|
|
|
BodyIdsFittingStandard = PetType::StandardBodyIds + [0]
|
|
|
|
scope :fitting_standard_body_ids, lambda {
|
|
|
|
where(arel_table[:body_id].in(BodyIdsFittingStandard))
|
2010-06-07 13:33:43 -07:00
|
|
|
}
|
2010-05-20 16:56:08 -07:00
|
|
|
|
2010-05-20 16:04:56 -07:00
|
|
|
def local_url
|
|
|
|
uri = URI.parse(url)
|
|
|
|
uri.host = RemoteImpressHost
|
|
|
|
pieces = uri.path.split('/')
|
|
|
|
uri.path = "/assets/swf/outfit/#{pieces[2]}/#{pieces[4..7].join('/')}"
|
|
|
|
uri.to_s
|
|
|
|
end
|
|
|
|
|
2010-05-20 16:56:08 -07:00
|
|
|
def as_json(options={})
|
2010-05-20 16:04:56 -07:00
|
|
|
{
|
|
|
|
:id => id,
|
|
|
|
:depth => depth,
|
2010-05-20 17:25:36 -07:00
|
|
|
:local_url => local_url,
|
2010-06-07 16:50:49 -07:00
|
|
|
:body_id => body_id,
|
|
|
|
:zone_id => zone_id
|
2010-05-20 16:04:56 -07:00
|
|
|
}
|
|
|
|
end
|
2010-06-09 19:56:47 -07:00
|
|
|
|
|
|
|
def zone
|
|
|
|
@zone ||= Zone.find(zone_id)
|
|
|
|
end
|
2010-10-07 07:46:23 -07:00
|
|
|
|
|
|
|
def origin_pet_type=(pet_type)
|
|
|
|
self.body_id = pet_type.body_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def origin_biology_data=(data)
|
|
|
|
self.type = 'biology'
|
|
|
|
self.zone_id = data[:zone_id].to_i
|
|
|
|
self.url = data[:asset_url]
|
|
|
|
self.zones_restrict = data[:zones_restrict]
|
|
|
|
end
|
|
|
|
|
|
|
|
def origin_object_data=(data)
|
|
|
|
self.type = 'object'
|
|
|
|
self.zone_id = data[:zone_id].to_i
|
|
|
|
self.url = data[:asset_url]
|
|
|
|
end
|
2010-05-16 12:01:38 -07:00
|
|
|
end
|