Sha256: b9edffcfe0e39a8faff9b5f72c48a991a007151f96fae4891ee8fa64038993f1

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

require 'xml/mapping_extensions'
require 'stash/wrapper/identifier_type'

module Stash
  module Wrapper

    # Mapping class for `<st:identifier>`
    class Identifier
      include ::XML::Mapping
      typesafe_enum_node :type, '@type', class: IdentifierType, default_value: nil
      text_node :value, '.', default_value: nil

      # Creates a new {Identifier}
      def initialize(type:, value:)
        fail ArgumentError, "Identifier type does not appear to be an IdentifierType: #{type || 'nil'}" unless type && type.is_a?(IdentifierType)
        fail ArgumentError, "Identifier value does not appear to be a non-empty string: #{value.inspect}" if value.to_s.strip.empty?
        self.type = type
        self.value = value
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stash-wrapper-0.1.11.1 lib/stash/wrapper/identifier.rb
stash-wrapper-0.1.11 lib/stash/wrapper/identifier.rb
stash-wrapper-0.1.10 lib/stash/wrapper/identifier.rb