Class: CloudFS::Container
Overview
Base class for Folder
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Item
#blocklist_id, #blocklist_key, #date_content_last_modified, #date_created, #date_meta_last_modified, #id, #is_mirrored, #name, #parent_id, #type, #url, #version
Instance Method Summary collapse
-
#initialize(rest_adapter, parent: nil, parent_state: nil, in_trash: false, in_share: false, **properties) ⇒ Container
constructor
A new instance of Container.
-
#list ⇒ Array<Folder, File>
List contents of this container.
Methods inherited from Item
#application_data, #application_data=, #change_attributes, #copy, #delete, #exists?, #in_share?, #in_trash?, #move, #old_version?, #path, #refresh, #restore, #save, #versions
Constructor Details
#initialize(rest_adapter, parent: nil, parent_state: nil, in_trash: false, in_share: false, **properties) ⇒ Container
Returns a new instance of Container.
15 16 17 18 19 20 21 |
# File 'lib/cloudfs/container.rb', line 15
def initialize(rest_adapter, parent: nil, parent_state: nil, in_trash: false,
in_share: false, ** properties)
fail RestAdapter::Errors::ArgumentError,
"Invalid item of type #{properties[:type]}" unless properties[:type] ==
'folder' || properties[:type] == 'root'
super
end
|
Instance Method Details
#list ⇒ Array<Folder, File>
List contents of this container
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cloudfs/container.rb', line 28
def list
fail RestAdapter::Errors::InvalidItemError,
'Operation not allowed as item does not exist anymore' unless exists?
if @in_share
response = @rest_adapter.browse_share(@state[:share_key], path: @url).fetch(:items)
elsif @in_trash
response = @rest_adapter.browse_trash(path: @url).fetch(:items)
else
response = @rest_adapter.list_folder(path: @url, depth: 1)
end
FileSystemCommon.create_items_from_hash_array(
response,
@rest_adapter,
parent: @url,
in_share: @in_share,
in_trash: @in_trash,
parent_state: @state)
end
|