Class: Medusa::Repository
- Inherits:
-
Object
- Object
- Medusa::Repository
- Includes:
- Resource
- Defined in:
- lib/medusa/repository.rb
Overview
Represents a Medusa repository node.
Class Method Summary collapse
-
.with_id(id) ⇒ Medusa::Repository
Returns a new instance with the given ID.
-
.with_uuid(uuid) ⇒ Medusa::Repository
Returns a new instance with the given UUID.
Instance Method Summary collapse
- #collections ⇒ Enumerable<Medusa::Collection>
- #contact_email ⇒ String
- #email ⇒ String
- #home_url ⇒ String
-
#initialize ⇒ Repository
constructor
A new instance of Repository.
- #ldap_admin_domain ⇒ String
- #ldap_admin_group ⇒ String
-
#load ⇒ Object
Updates the instance with current properties from Medusa.
- #title ⇒ String
-
#url ⇒ String
Absolute URI of the corresponding Medusa resource.
Methods included from Resource
Methods included from Uuidable
Constructor Details
#initialize ⇒ Repository
Returns a new instance of Repository.
38 39 40 41 42 43 44 |
# File 'lib/medusa/repository.rb', line 38 def initialize @loading = false @loaded = false @collections = Set.new @id = nil @uuid = nil end |
Class Method Details
.with_id(id) ⇒ Medusa::Repository
Returns a new instance with the given ID. Existence is not checked, so an instance is returned regardless of whether the ID is valid.
19 20 21 22 23 |
# File 'lib/medusa/repository.rb', line 19 def self.with_id(id) repo = Repository.new repo.instance_variable_set('@id', id) repo end |
.with_uuid(uuid) ⇒ Medusa::Repository
Returns a new instance with the given UUID. Existence is not checked, so an instance is returned regardless of whether the UUID is valid.
32 33 34 35 36 |
# File 'lib/medusa/repository.rb', line 32 def self.with_uuid(uuid) repo = Repository.new repo.instance_variable_set('@uuid', uuid) repo end |
Instance Method Details
#collections ⇒ Enumerable<Medusa::Collection>
49 50 51 52 |
# File 'lib/medusa/repository.rb', line 49 def collections load @collections end |
#contact_email ⇒ String
57 58 59 60 |
# File 'lib/medusa/repository.rb', line 57 def contact_email load @contact_email end |
#email ⇒ String
65 66 67 68 |
# File 'lib/medusa/repository.rb', line 65 def email load @email end |
#home_url ⇒ String
73 74 75 76 |
# File 'lib/medusa/repository.rb', line 73 def home_url load @home_url end |
#ldap_admin_domain ⇒ String
81 82 83 84 |
# File 'lib/medusa/repository.rb', line 81 def ldap_admin_domain load @ldap_admin_domain end |
#ldap_admin_group ⇒ String
89 90 91 92 |
# File 'lib/medusa/repository.rb', line 89 def ldap_admin_group load @ldap_admin_group end |
#load ⇒ Object
Updates the instance with current properties from Medusa.
It should not typically be necessary to use this method publicly.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/medusa/repository.rb', line 107 def load return if @loading || @loaded @loading = true struct = fetch_body @contact_email = struct['contact_email'] @email = struct['email'] @home_url = struct['url'] @id = struct['id'] @ldap_admin_domain = struct['ldap_admin_domain'] @ldap_admin_group = struct['ldap_admin_group'] @title = struct['title'] @uuid = struct['uuid'] struct['collections'].each do |col_struct| @collections << Collection.with_id(col_struct['id']) end @loaded = true ensure @loading = false end |
#title ⇒ String
97 98 99 100 |
# File 'lib/medusa/repository.rb', line 97 def title load @title end |
#url ⇒ String
Returns Absolute URI of the corresponding Medusa resource.
130 131 132 133 134 |
# File 'lib/medusa/repository.rb', line 130 def url [Client.configuration[:medusa_base_url].chomp('/'), 'repositories', self.id].join('/') end |