Class: Medusa::FileGroup
- Inherits:
-
Object
- Object
- Medusa::FileGroup
- Includes:
- Resource
- Defined in:
- lib/medusa/file_group.rb
Overview
Represents a Medusa file group.
Class Method Summary collapse
-
.with_id(id) ⇒ Medusa::FileGroup
Returns a new instance with the given ID.
-
.with_uuid(uuid) ⇒ Medusa::FileGruop
Returns a new instance with the given UUID.
Instance Method Summary collapse
-
#collection ⇒ Medusa::Collection
Owning collection.
-
#directory ⇒ Medusa::Directory
For instances with a #storage_level of
bit_level
, the root directory of the file group. - #external_file_location ⇒ String
-
#initialize ⇒ FileGroup
constructor
A new instance of FileGroup.
-
#load ⇒ Object
Updates the instance with current properties from Medusa.
- #storage_level ⇒ String
- #title ⇒ String
-
#url ⇒ String
Absolute URI of the corresponding Medusa resource.
Methods included from Resource
Methods included from Uuidable
Constructor Details
#initialize ⇒ FileGroup
Returns a new instance of FileGroup.
36 37 38 39 40 41 42 43 44 |
# File 'lib/medusa/file_group.rb', line 36 def initialize @loading = false @loaded = false @collection = nil @directory = nil @directory_id = nil @id = nil @uuid = nil end |
Class Method Details
.with_id(id) ⇒ Medusa::FileGroup
Returns a new instance with the given ID. Existence is not checked, so an instance is returned regardless of whether the ID is valid.
17 18 19 20 21 |
# File 'lib/medusa/file_group.rb', line 17 def self.with_id(id) fg = FileGroup.new fg.instance_variable_set('@id', id) fg end |
.with_uuid(uuid) ⇒ Medusa::FileGruop
Returns a new instance with the given UUID. Existence is not checked, so an instance is returned regardless of whether the UUID is valid.
30 31 32 33 34 |
# File 'lib/medusa/file_group.rb', line 30 def self.with_uuid(uuid) fg = FileGroup.new fg.instance_variable_set('@uuid', uuid) fg end |
Instance Method Details
#collection ⇒ Medusa::Collection
Returns Owning collection.
49 50 51 52 |
# File 'lib/medusa/file_group.rb', line 49 def collection load @collection ||= Collection.with_id(@collection_id) end |
#directory ⇒ Medusa::Directory
Returns For instances with a #storage_level of bit_level
, the root directory of the file group. Otherwise, nil
.
59 60 61 62 63 64 65 66 |
# File 'lib/medusa/file_group.rb', line 59 def directory load if @directory_id @directory ||= Directory.with_id(@directory_id) else nil end end |
#external_file_location ⇒ String
71 72 73 74 |
# File 'lib/medusa/file_group.rb', line 71 def external_file_location load @external_file_location end |
#load ⇒ Object
Updates the instance with current properties from Medusa.
It should not typically be necessary to use this method publicly.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/medusa/file_group.rb', line 97 def load return if @loading || @loaded @loading = true struct = fetch_body @collection_id = struct['collection_id'] @directory_id = struct['cfs_directory']['id'] if struct['cfs_directory'] @external_file_location = struct['external_file_location'] @id = struct['id'] @storage_level = struct['storage_level'] @title = struct['title'] @uuid = struct['uuid'] @loaded = true ensure @loading = false end |
#storage_level ⇒ String
79 80 81 82 |
# File 'lib/medusa/file_group.rb', line 79 def storage_level load @storage_level end |
#title ⇒ String
87 88 89 90 |
# File 'lib/medusa/file_group.rb', line 87 def title load @title end |
#url ⇒ String
Returns Absolute URI of the corresponding Medusa resource.
116 117 118 119 120 |
# File 'lib/medusa/file_group.rb', line 116 def url [::Medusa::Client.configuration[:medusa_base_url].chomp('/'), 'file_groups', self.id].join('/') end |