app/models/s3_relay/upload.rb in s3_relay-0.0.2 vs app/models/s3_relay/upload.rb in s3_relay-0.0.3

- old
+ new

@@ -8,10 +8,11 @@ validates :filename, presence: true validates :content_type, presence: true validates :pending_at, presence: true after_initialize :finalize + after_create :notify_parent def self.pending where(state: "pending") end @@ -27,9 +28,17 @@ state == "imported" end def mark_imported! update_attributes(state: "imported", imported_at: Time.now) + end + + def notify_parent + return unless parent.present? + + if parent.respond_to?(:import_upload) + parent.import_upload(id) + end end def private_url S3Relay::PrivateUrl.new(uuid, filename).generate end