Sha256: 37e0c8b7f0485fda36908a6085908c8e4805384cbd8070220dc35542fc40e4af

Contents?: true

Size: 1010 Bytes

Versions: 20

Compression:

Stored size: 1010 Bytes

Contents

module Ddr::Models::Structures
  #
  # Wraps a Nokogiri (XML) 'agent' node
  #
  class Agent < SimpleDelegator

    ROLE_CREATOR = 'CREATOR'.freeze

    NAME_REPOSITORY_DEFAULT = 'REPOSITORY DEFAULT'.freeze

    def id
      self['ID']
    end

    def role
      self['ROLE']
    end

    def otherrole
      self['OTHERROLE']
    end

    def type
      self['TYPE']
    end

    def othertype
      self['OTHERTYPE']
    end

    def name
      xpath('xmlns:name').first.content
    end

    def self.build(args)
      node = Nokogiri::XML::Node.new('agent', args[:document])
      node['ID'] = args[:id] if args[:id]
      node['ROLE'] = args[:role] if args[:role]
      node['OTHERROLE'] = args[:otherrole] if args[:otherrole]
      node['TYPE'] = args[:type] if args[:type]
      node['OTHERTYPE'] = args[:othertype] if args[:othertype]
      name_node = Nokogiri::XML::Node.new('name', args[:document])
      name_node.content = args[:name]
      node.add_child(name_node)
      node
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ddr-models-2.11.0 lib/ddr/models/structures/agent.rb
ddr-models-2.10.2 lib/ddr/models/structures/agent.rb
ddr-models-2.10.1 lib/ddr/models/structures/agent.rb
ddr-models-2.10.0 lib/ddr/models/structures/agent.rb
ddr-models-2.10.0.rc2 lib/ddr/models/structures/agent.rb
ddr-models-2.10.0.rc1 lib/ddr/models/structures/agent.rb
ddr-models-2.9.2 lib/ddr/models/structures/agent.rb
ddr-models-2.9.1 lib/ddr/models/structures/agent.rb
ddr-models-2.9.0 lib/ddr/models/structures/agent.rb
ddr-models-2.9.0.rc1 lib/ddr/models/structures/agent.rb
ddr-models-2.8.0 lib/ddr/models/structures/agent.rb
ddr-models-2.8.0.rc1 lib/ddr/models/structures/agent.rb
ddr-models-2.7.6 lib/ddr/models/structures/agent.rb
ddr-models-2.7.5 lib/ddr/models/structures/agent.rb
ddr-models-2.7.4 lib/ddr/models/structures/agent.rb
ddr-models-2.7.3 lib/ddr/models/structures/agent.rb
ddr-models-2.7.2 lib/ddr/models/structures/agent.rb
ddr-models-2.7.1 lib/ddr/models/structures/agent.rb
ddr-models-2.7.0 lib/ddr/models/structures/agent.rb
ddr-models-2.7.0.rc1 lib/ddr/models/structures/agent.rb