lib/datacite/mapping/name_identifier.rb in datacite-mapping-0.1.6 vs lib/datacite/mapping/name_identifier.rb in datacite-mapping-0.1.7

- old
+ new

@@ -4,28 +4,10 @@ module Mapping # Uniquely identifies an individual or legal entity, according to various schemes. class NameIdentifier include XML::Mapping - root_element_name 'nameIdentifier' - - # @!attribute [rw] scheme - # @return [String] the name identifier scheme. Cannot be nil. - text_node :scheme, '@nameIdentifierScheme' - # @!attribute [rw] scheme_uri - # @return [URI, nil] the URI of the identifier scheme. Optional. - uri_node :scheme_uri, '@schemeURI', default_value: nil - # @!attribute [rw] value - # @return [String] the identifier value. Cannot be nil. - text_node :value, 'text()' - - maybe_alias :_scheme=, :scheme= - private :_scheme= - - maybe_alias :_value=, :value= - private :_value= - # Initializes a new {NameIdentifier} # @param scheme [Scheme] the name identifier scheme. Cannot be nil. # @param scheme_uri [URI, nil] the URI of the identifier scheme. Optional. # @param value [String] the identifier value. Cannot be nil. def initialize(scheme:, scheme_uri: nil, value:) @@ -34,15 +16,28 @@ self.value = value end def scheme=(v) fail ArgumentError, 'Scheme cannot be empty or nil' unless v && !v.empty? - self._scheme = v + @scheme = v end def value=(v) fail ArgumentError, 'Value cannot be empty or nil' unless v && !v.empty? - self._value = v + @value = v end + + root_element_name 'nameIdentifier' + + # @!attribute [rw] scheme + # @return [String] the name identifier scheme. Cannot be nil. + text_node :scheme, '@nameIdentifierScheme' + # @!attribute [rw] scheme_uri + # @return [URI, nil] the URI of the identifier scheme. Optional. + uri_node :scheme_uri, '@schemeURI', default_value: nil + # @!attribute [rw] value + # @return [String] the identifier value. Cannot be nil. + text_node :value, 'text()' + end end end