Class: SAML2::IndexedObject::Array

Inherits:
Array
  • Object
show all
Defined in:
lib/saml2/indexed_object.rb

Overview

Keeps an Array of SAML2::IndexedObjects in their indexed order.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(objects = nil) ⇒ Array

Returns a new instance of Array.



47
48
49
50
# File 'lib/saml2/indexed_object.rb', line 47

def initialize(objects = nil)
  replace(objects.sort_by { |object| object.index || 0 }) if objects
  re_index
end

Instance Attribute Details

#defaultIndexedObject (readonly)

Returns the first object which is set as the default, or the first object if none are set as the default.

Returns:



41
42
43
# File 'lib/saml2/indexed_object.rb', line 41

def default
  @default
end

Class Method Details

.from_xml(nodes) ⇒ Object



43
44
45
# File 'lib/saml2/indexed_object.rb', line 43

def self.from_xml(nodes)
  new(nodes.map { |node| name.split('::')[1..-2].inject(SAML2) { |mod, klass| mod.const_get(klass) }.from_xml(node) }).freeze
end

Instance Method Details

#<<(value) ⇒ Object



60
61
62
63
# File 'lib/saml2/indexed_object.rb', line 60

def <<(value)
  super
  re_index
end

#[](index) ⇒ Object



52
53
54
# File 'lib/saml2/indexed_object.rb', line 52

def [](index)
  @index[index]
end

#resolve(index) ⇒ Object



56
57
58
# File 'lib/saml2/indexed_object.rb', line 56

def resolve(index)
  index ? self[index] : default
end