Class: Hydra::RemoteIdentifier::RemoteServices::Doi

Inherits:
Hydra::RemoteIdentifier::RemoteService show all
Defined in:
lib/hydra/remote_identifier/remote_services/doi.rb

Constant Summary collapse

REQUIRED_ATTRIBUTES =
['target', 'creator', 'title', 'publisher', 'publicationyear' ].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration = {}) ⇒ Doi

Returns a new instance of Doi.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 11

def initialize(configuration = {})
  username = configuration.fetch(:username)
  password = configuration.fetch(:password)
  shoulder = configuration.fetch(:shoulder)
  url = configuration.fetch(:url)

  # This is specific for the creation of DOIs
  @uri = URI.parse(File.join(url, 'shoulder', shoulder))
  @uri.user = username
  @uri.password = password
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



10
11
12
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 10

def uri
  @uri
end

Instance Method Details

#call(payload) ⇒ Object



28
29
30
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 28

def call(payload)
  request(data_for_create(payload.with_indifferent_access))
end

#valid_attribute?(attribute_name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 24

def valid_attribute?(attribute_name)
  REQUIRED_ATTRIBUTES.include?(attribute_name.to_s)
end