Class: Shibkit::MetaMeta::MetadataItem
Overview
Base class for all MetaMeta metadata classes
Constant Summary
collapse
- ROOT_ELEMENT =
Element and attribute used to select XML for new objects
'SomeThingThatIsntThere'
- TARGET_ATTR =
'ID'
- REQUIRED_QUACKS =
[:bananas]
- NAMESPACES =
Additional namespaces that Nokogiri needs to know about
{
'ukfedlabel' => 'http://ukfederation.org.uk/2006/11/label',
'elab' => 'http://eduserv.org.uk/labels',
'wayf' => 'http://sdss.ac.uk/2006/06/WAYF',
'mdui' => 'urn:oasis:names:tc:SAML:metadata:ui',
'saml' => 'urn:oasis:names:tc:SAML:2.0:assertion',
'shibmd' => 'urn:mace:shibboleth:metadata:1.0'
}
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(xml = nil, target = nil, options = {}, &block) ⇒ MetadataItem
New object takes XML (as libXML object or text)
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 50
def initialize(xml=nil, target=nil, options={}, &block)
@read_at = Time.new
@noko = nil
@source_xml = nil
from_xml(xml) if xml
self.instance_eval(&block) if block
end
|
Instance Attribute Details
#read_at ⇒ Object
Returns the value of attribute read_at.
47
48
49
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 47
def read_at
@read_at
end
|
Instance Method Details
#filter ⇒ Object
Make sure the object is suitable. Return nil if bad, object if good
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 65
def filter
self.class::REQUIRED_QUACKS.each do |method|
return nil unless self.respond_to? method
return nil unless self.send(method)
end
return self
end
|
#from_xml(xml, target = nil, options = {}) ⇒ Object
140
141
142
143
144
145
146
147
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 140
def from_xml(xml, target=nil, options={})
prepare_xml(xml)
select_xml(target, options)
parse_xml
purge_xml if ::Shibkit::MetaMeta.config.purge_xml?
end
|
#hashed_id ⇒ Object
79
80
81
82
83
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 79
def hashed_id
return Digest::SHA1.hexdigest uri || url || to_s
end
|
#parsed_xml ⇒ Object
115
116
117
118
119
120
121
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 115
def parsed_xml
prepare_xml(@noko) if @noko.kind_of? String
return @noko
end
|
#purge_xml(cascade = true) ⇒ Object
123
124
125
126
127
128
129
130
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 123
def purge_xml(cascade=true)
@noko = nil
@source_xml = nil
cascade_method(:purge_xml, true) if cascade
end
|
#source_xml ⇒ Object
109
110
111
112
113
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 109
def source_xml
return @source_xml
end
|
#textify_xml(cascade = true) ⇒ Object
132
133
134
135
136
137
138
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 132
def textify_xml(cascade=true)
@noko = @noko.to_s
cascade_method(:textify_xml, true) if cascade
end
|
#to_hash ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 85
def to_hash
raise "Not Implemented!"
return {}
end
|
#to_rdf ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 93
def to_rdf
raise "Not Implemented!"
return
end
|
#to_xml ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/shibkit/meta_meta/metadata_item.rb', line 101
def to_xml
raise "Not Implemented!"
return
end
|