Class: Ddr::Models::Structures::Agent

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ddr/models/structures/agent.rb

Overview

Wraps a Nokogiri (XML) ‘agent’ node

Constant Summary collapse

ROLE_CREATOR =
'CREATOR'.freeze
NAME_REPOSITORY_DEFAULT =
'REPOSITORY DEFAULT'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ddr/models/structures/agent.rb', line 35

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

Instance Method Details

#idObject



11
12
13
# File 'lib/ddr/models/structures/agent.rb', line 11

def id
  self['ID']
end

#nameObject



31
32
33
# File 'lib/ddr/models/structures/agent.rb', line 31

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

#otherroleObject



19
20
21
# File 'lib/ddr/models/structures/agent.rb', line 19

def otherrole
  self['OTHERROLE']
end

#othertypeObject



27
28
29
# File 'lib/ddr/models/structures/agent.rb', line 27

def othertype
  self['OTHERTYPE']
end

#roleObject



15
16
17
# File 'lib/ddr/models/structures/agent.rb', line 15

def role
  self['ROLE']
end

#typeObject



23
24
25
# File 'lib/ddr/models/structures/agent.rb', line 23

def type
  self['TYPE']
end