1
0
Fork 0
forked from OpenNeo/impress

Reorder the higher-up lines of SwfAsset

A lot of stuff was mixed together, including methods interrupting the
scopes and relationships, oops! Fixed!
This commit is contained in:
Emi Matchu 2024-02-24 15:22:14 -08:00
parent e8737a520e
commit cf1cdf7e7d

View file

@ -8,6 +8,9 @@ class SwfAsset < ApplicationRecord
# We use the `type` column to mean something other than what Rails means!
self.inheritance_column = nil
# Used in `item_is_body_specific?`. (TODO: Could we refactor this out?)
attr_accessor :item
IMAGE_SIZES = {
:small => [150, 150],
:medium => [300, 300],
@ -16,9 +19,16 @@ class SwfAsset < ApplicationRecord
belongs_to :zone
has_many :parent_swf_asset_relationships
has_one :contribution, :as => :contributed, :inverse_of => :contributed
has_many :parent_swf_asset_relationships
before_validation :normalize_manifest_url, if: :manifest_url?
delegate :depth, :to => :zone
scope :biology_assets, -> { where(:type => PetState::SwfAssetType) }
scope :object_assets, -> { where(:type => Item::SwfAssetType) }
PARTITION_COUNT = 3
PARTITION_DIGITS = 3
PARTITION_ID_LENGTH = PARTITION_COUNT * PARTITION_DIGITS
@ -42,16 +52,6 @@ class SwfAsset < ApplicationRecord
"#{image_version}"
end
attr_accessor :item
has_one :contribution, :as => :contributed, :inverse_of => :contributed
has_many :parent_swf_asset_relationships
delegate :depth, :to => :zone
scope :biology_assets, -> { where(:type => PetState::SwfAssetType) }
scope :object_assets, -> { where(:type => Item::SwfAssetType) }
# To manually change the body ID without triggering the usual change to 0,
# use this override method.
def override_body_id(new_body_id)