class MountableFileServer::FileAccessor
Attributes
configuration[R]
uid[R]
Public Class Methods
new(uid, configuration = MountableFileServer.config)
click to toggle source
# File lib/mountable_file_server/file_accessor.rb, line 11 def initialize(uid, configuration = MountableFileServer.config) @uid = uid @configuration = configuration end
Public Instance Methods
exist?()
click to toggle source
# File lib/mountable_file_server/file_accessor.rb, line 28 def exist? pathnames.any? { |p| p.file? } end
pathname()
click to toggle source
# File lib/mountable_file_server/file_accessor.rb, line 24 def pathname pathnames.find(-> { raise MissingFile }) { |p| p.file? } end
permanent_pathname()
click to toggle source
# File lib/mountable_file_server/file_accessor.rb, line 20 def permanent_pathname Pathname(configuration.storage_path) + uid.type + uid end
temporary_pathname()
click to toggle source
# File lib/mountable_file_server/file_accessor.rb, line 16 def temporary_pathname Pathname(configuration.storage_path) + 'tmp' + uid end
url()
click to toggle source
# File lib/mountable_file_server/file_accessor.rb, line 32 def url raise NotAccessibleViaURL unless uid.public? URI.new (Pathname(configuration.base_url) + uid).to_s end
Private Instance Methods
pathnames()
click to toggle source
# File lib/mountable_file_server/file_accessor.rb, line 39 def pathnames [permanent_pathname, temporary_pathname] end