Skip to content

Commit

Permalink
Explicit initializer for StacksFile
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jun 28, 2024
1 parent 333defb commit b538ecb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/file_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ def cache_headers
end

def current_file
@file ||= StacksFile.new(file_params)
@file ||= StacksFile.new(id: params[:id], file_name: params[:file_name])
end
end
8 changes: 6 additions & 2 deletions app/models/stacks_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
# Represents a file on disk in stacks. A StacksFile may be downloaded and
# may be the file that backs a StacksImage or StacksMediaStream
class StacksFile
include ActiveModel::Model
include ActiveModel::Validations

attr_accessor :id, :file_name
def initialize(id:, file_name:)
@id = id
@file_name = file_name
end

attr_reader :id, :file_name

validates :id, format: { with: StorageRoot::DRUID_PARTS_PATTERN }

Expand Down

0 comments on commit b538ecb

Please sign in to comment.