Class: SAML2::Attribute
Direct Known Subclasses
X500
Defined Under Namespace
Modules: NameFormats
Classes: X500
Instance Attribute Summary collapse
#friendly_name, #name, #name_format
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
load_object_array, load_string_array, #to_s, #to_xml
Constructor Details
#initialize(name = nil, value = nil, friendly_name = nil, name_format = nil) ⇒ Attribute
Returns a new instance of Attribute.
57
58
59
60
|
# File 'lib/saml2/attribute.rb', line 57
def initialize(name = nil, value = nil, friendly_name = nil, name_format = nil)
super(name, friendly_name, name_format)
@value = value
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
55
56
57
|
# File 'lib/saml2/attribute.rb', line 55
def value
@value
end
|
Class Method Details
.create(name, value = nil) ⇒ Object
49
50
51
52
|
# File 'lib/saml2/attribute.rb', line 49
def create(name, value = nil)
klass = subclasses.find { |klass| klass.recognizes?(name) } || self
klass.new(name, value)
end
|
.from_xml(node) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/saml2/attribute.rb', line 36
def from_xml(node)
super unless self == Attribute
klass = subclasses.find { |klass| klass.recognizes?(node) }
if klass
klass.from_xml(node)
else
super
end
end
|
.inherited(klass) ⇒ Object
32
33
34
|
# File 'lib/saml2/attribute.rb', line 32
def inherited(klass)
subclasses << klass
end
|
.subclasses ⇒ Object
28
29
30
|
# File 'lib/saml2/attribute.rb', line 28
def subclasses
@subclasses ||= []
end
|
Instance Method Details
#build(builder) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/saml2/attribute.rb', line 62
def build(builder)
builder['saml'].Attribute('Name' => name) do |builder|
builder.parent['FriendlyName'] = friendly_name if friendly_name
builder.parent['NameFormat'] = name_format if name_format
Array(value).each do |val|
xsi_type, val = convert_to_xsi(value)
builder['saml'].AttributeValue(val) do |builder|
builder.parent['xsi:type'] = xsi_type if xsi_type
end
end
end
end
|
#from_xml(node) ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/saml2/attribute.rb', line 75
def from_xml(node)
@value = node.xpath('saml:AttributeValue', Namespaces::ALL).map do |node|
convert_from_xsi(node['xsi:type'], node.content && node.content.strip)
end
@value = @value.first if @value.length == 1
super
end
|