Class: Medusa::Collection
- Inherits:
-
Object
- Object
- Medusa::Collection
- Includes:
- Resource
- Defined in:
- lib/medusa/collection.rb
Overview
Represents a Medusa collection.
Class Method Summary collapse
-
.with_id(id) ⇒ Medusa::Collection
Returns a new instance with the given ID.
-
.with_uuid(uuid) ⇒ Medusa::Collection
Returns a new instance with the given UUID.
Instance Method Summary collapse
- #access_url ⇒ String
- #contact_email ⇒ String
- #description ⇒ String
- #description_html ⇒ String
- #external_id ⇒ String
- #file_groups ⇒ Enumerable<Medusa::FileGroup>
-
#initialize ⇒ Collection
constructor
A new instance of Collection.
-
#load ⇒ Object
Updates the instance with current properties from Medusa.
- #physical_collection_url ⇒ String
- #private_description ⇒ String
- #published? ⇒ Boolean
- #repository ⇒ Medusa::Repository
- #representative_image ⇒ String
-
#representative_item ⇒ String
Digital Library item UUID.
- #title ⇒ String
-
#url ⇒ String
Absolute URI of the corresponding Medusa resource.
Methods included from Resource
Methods included from Uuidable
Constructor Details
#initialize ⇒ Collection
Returns a new instance of Collection.
36 37 38 39 40 41 42 |
# File 'lib/medusa/collection.rb', line 36 def initialize @loading = false @loaded = false @file_groups = Set.new @id = nil @uuid = nil end |
Class Method Details
.with_id(id) ⇒ Medusa::Collection
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/collection.rb', line 17 def self.with_id(id) col = Collection.new col.instance_variable_set('@id', id) col end |
.with_uuid(uuid) ⇒ Medusa::Collection
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/collection.rb', line 30 def self.with_uuid(uuid) col = Collection.new col.instance_variable_set('@uuid', uuid) col end |
Instance Method Details
#access_url ⇒ String
47 48 49 50 |
# File 'lib/medusa/collection.rb', line 47 def access_url load @access_url end |
#contact_email ⇒ String
55 56 57 58 |
# File 'lib/medusa/collection.rb', line 55 def contact_email load @contact_email end |
#description ⇒ String
63 64 65 66 |
# File 'lib/medusa/collection.rb', line 63 def description load @description end |
#description_html ⇒ String
71 72 73 74 |
# File 'lib/medusa/collection.rb', line 71 def description_html load @description_html end |
#external_id ⇒ String
79 80 81 82 |
# File 'lib/medusa/collection.rb', line 79 def external_id load @external_id end |
#file_groups ⇒ Enumerable<Medusa::FileGroup>
87 88 89 90 |
# File 'lib/medusa/collection.rb', line 87 def file_groups load @file_groups end |
#load ⇒ Object
Updates the instance with current properties from Medusa.
It should not typically be necessary to use this method publicly.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/medusa/collection.rb', line 153 def load return if @loading || @loaded @loading = true struct = fetch_body @access_url = struct['access_url'] @contact_email = struct['contact_email'] @description = struct['description'] @description_html = struct['description_html'] @external_id = struct['external_id'] @id = struct['id'] @physical_collection_url = struct['physical_collection_url'] @private_description = struct['private_description'] @published = struct['publish'] @representative_image = struct['representative_image'] @representative_item = struct['representative_item'] @repository_uuid = struct['repository_uuid'] @title = struct['title'] @uuid = struct['uuid'] struct['file_groups'].each do |group| @file_groups << FileGroup.with_id(group['id']) end @loaded = true ensure @loading = false end |
#physical_collection_url ⇒ String
95 96 97 98 |
# File 'lib/medusa/collection.rb', line 95 def physical_collection_url load @physical_collection_url end |
#private_description ⇒ String
103 104 105 106 |
# File 'lib/medusa/collection.rb', line 103 def private_description load @private_description end |
#published? ⇒ Boolean
111 112 113 114 |
# File 'lib/medusa/collection.rb', line 111 def published? load @published end |
#repository ⇒ Medusa::Repository
119 120 121 122 |
# File 'lib/medusa/collection.rb', line 119 def repository load @repository ||= Repository.with_uuid(@repository_uuid) end |
#representative_image ⇒ String
127 128 129 130 |
# File 'lib/medusa/collection.rb', line 127 def representative_image load @representative_image end |
#representative_item ⇒ String
Returns Digital Library item UUID.
135 136 137 138 |
# File 'lib/medusa/collection.rb', line 135 def representative_item load @representative_item end |
#title ⇒ String
143 144 145 146 |
# File 'lib/medusa/collection.rb', line 143 def title load @title end |
#url ⇒ String
Returns Absolute URI of the corresponding Medusa resource.
182 183 184 185 186 |
# File 'lib/medusa/collection.rb', line 182 def url [::Medusa::Client.configuration[:medusa_base_url].chomp('/'), 'collections', self.id].join('/') end |