Class: LayerVault::Folder

Inherits:
Model
  • Object
show all
Defined in:
lib/layervault/folder.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

build_associations, #set_context

Class Method Details

.for(organization, project, folder_path) ⇒ Object



4
5
6
7
8
# File 'lib/layervault/folder.rb', line 4

def for(organization, project, folder_path)
  resp = MultiJson.decode(LayerVault.client.folder(organization, project, folder_path))
  instance = build_associations(resp, :folders, :files)
  instance.set_context(organization: organization, project: project, folder_path: folder_path)
end

Instance Method Details

#create_file(file_name, options = {}) ⇒ Object



15
16
17
# File 'lib/layervault/folder.rb', line 15

def create_file(file_name, options={})
  LayerVault.client.create_file( context.organization, context.project_name, context.folder_path, file_name, options[:md5], options[:local_file_path], options[:content_type] )
end

#delete_file(file_name, md5) ⇒ Object



11
12
13
# File 'lib/layervault/folder.rb', line 11

def delete_file(file_name, md5)
  LayerVault.client.delete_file( context.organization, context.project_name, context.folder_path, file_name, md5: md5 )
end

#move_file(file_name, new_folder, new_filename) ⇒ Object



19
20
21
# File 'lib/layervault/folder.rb', line 19

def move_file(file_name, new_folder, new_filename)
  LayerVault.client.move_file( context.organization, context.project_name, context.folder_path, file_name, new_folder: new_folder, new_filename: new_filename)
end

#sync_check(file_name, options = {}) ⇒ Object



23
24
25
# File 'lib/layervault/folder.rb', line 23

def sync_check(file_name, options={})
  LayerVault.client.sync_check( context.organization, context.project_name, context.folder_path, file_name, md5: options[:md5] )
end