diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index 38e62fad..a3bbf675 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -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)