Class: FileStore::WebDAV::WebDAVStoreFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/filestore/factory.rb

Overview

WebDAVStore factory class

Class Method Summary collapse

Class Method Details

.create(root_path, host, prefix, port = 80, user = '', password = '', observable = false, logger = StdoutLogger) ⇒ Object

Creates a WebDAV file-store instance

Arguments:

root_path: The base path directory
host: The WebDAV host
prefix: The path prefix for any URL
port (optional): The WebDAV port
user (optional): HTTP user
password (optional): HTTP password 
observable (optional): Determines wether this instance should support observation
logger (optional): The logging facility

Returns:

A new instance of WebDAVStore


233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/filestore/factory.rb', line 233

def self.create(root_path, host, prefix, port = 80, user = '', password = '', observable = false, logger = StdoutLogger)
  store = nil
  
  begin
    store = WebDAVStore.new host, port, user, password, root_path, logger
    store.connection.path_prefix = prefix
    
    if observable then
      logger.debug "Extending instance with module 'ObservedSubject'"
      
      store.extend ObservedSubject
      store.initialize_obs 
    end
  rescue FileStoreException => e
    logger.debug "Couldn't create webdav store.\nReason: #{e.message}"
  end
  
  return store
end