Module: Hydra::RemoteIdentifier
- Defined in:
- lib/hydra/remote_identifier/mapper.rb,
lib/hydra/remote_identifier/minter.rb,
lib/hydra/remote_identifier/railtie.rb,
lib/hydra/remote_identifier/version.rb,
lib/hydra/remote_identifier/exceptions.rb,
lib/hydra/remote_identifier/registration.rb,
lib/hydra/remote_identifier/configuration.rb,
lib/hydra/remote_identifier/remote_service.rb,
lib/hydra/remote_identifier/minting_coordinator.rb,
lib/hydra/remote_identifier/remote_services/doi.rb,
lib/hydra/remote_identifier.rb
Defined Under Namespace
Modules: RemoteServices Classes: Configuration, DoiGenerator, InstallGenerator, InvalidServiceMapping, Mapper, Minter, MintingCoordinator, Railtie, Registration, RemoteService, RemoteServiceError
Constant Summary collapse
- VERSION =
"0.6.4"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Object
Used for configuring available RemoteService and any additional initialization requirements for those RemoteServices (i.e. credentials).
- .configure! ⇒ Object
-
.mint(remote_service_name, target) ⇒ Object
Using the RemoteService mint the corresponding remote identifier for the target.
-
.registered?(remote_service_name, target) {|@required, @optional| ... } ⇒ Boolean
(also: with_registered_remote_service)
Yields the specified RemoteService if it could be requested for the Target.
-
.remote_service(remote_service_name) ⇒ Object
Retrieve a valid RemoteService by name.
- .remote_uri_for(remote_service_name, identifier) ⇒ Object
-
.requested_remote_identifiers_for(target) ⇒ Object
Yields each RemoteService#name that is requested for the Target.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
38 39 40 |
# File 'lib/hydra/remote_identifier.rb', line 38 def configuration @configuration end |
Class Method Details
.configure {|config| ... } ⇒ Object
Used for configuring available RemoteService and any additional initialization requirements for those RemoteServices (i.e. credentials)
30 31 32 33 34 35 36 37 |
# File 'lib/hydra/remote_identifier.rb', line 30 def configure(&block) @configuration_block = block # The Rails load sequence means that some of the configured Targets may # not be loaded; As such I am not calling configure! instead relying on # Hydra::RemoteIdentifier::Railtie to handle the configure! call configure! unless defined?(Rails) end |
.configure! ⇒ Object
40 41 42 43 44 45 |
# File 'lib/hydra/remote_identifier.rb', line 40 def configure! if @configuration_block.respond_to?(:call) self.configuration ||= Configuration.new @configuration_block.call(configuration) end end |
.mint(remote_service_name, target) ⇒ Object
Using the RemoteService mint the corresponding remote identifier for the target. You must first configure the RemoteService and target’s class to define the attribute map. See Hydra::RemoteIdentifier.configure
132 133 134 135 136 |
# File 'lib/hydra/remote_identifier.rb', line 132 def mint(remote_service_name, target) registered?(remote_service_name, target) do |remote_service, coordinator| coordinator.call(target) end end |
.registered?(remote_service_name, target) {|@required, @optional| ... } ⇒ Boolean Also known as: with_registered_remote_service
Yields the specified RemoteService if it could be requested for the Target.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/hydra/remote_identifier.rb', line 73 def registered?(remote_service_name, target, &block) return false unless target.respond_to?(:registered_remote_identifier_minters) !!target.registered_remote_identifier_minters.detect do |coordinator| # require 'debugger'; debugger; true; if coordinator.remote_service.to_s == remote_service_name.to_s if block_given? if block.arity == 2 block.call(coordinator.remote_service, coordinator) else block.call(coordinator.remote_service) end end true end end end |
.remote_service(remote_service_name) ⇒ Object
Retrieve a valid RemoteService by name
54 55 56 |
# File 'lib/hydra/remote_identifier.rb', line 54 def remote_service(remote_service_name) configuration.find_remote_service(remote_service_name) end |
.remote_uri_for(remote_service_name, identifier) ⇒ Object
99 100 101 102 |
# File 'lib/hydra/remote_identifier.rb', line 99 def remote_uri_for(remote_service_name, identifier) remote_service = configuration.find_remote_service(remote_service_name) remote_service.remote_uri_for(identifier) end |
.requested_remote_identifiers_for(target) ⇒ Object
Yields each RemoteService#name that is requested for the Target.
113 114 115 116 117 118 119 120 121 |
# File 'lib/hydra/remote_identifier.rb', line 113 def requested_remote_identifiers_for(target) return false unless target.respond_to?(:registered_remote_identifier_minters) target.registered_remote_identifier_minters.each do |coordinator| remote_service = coordinator.remote_service if target.public_send(remote_service.accessor_name).to_i != 0 yield(remote_service) end end end |