class SAML2::IndexedObject::Array

Keeps an Array of {IndexedObject}s in their +index+ed order.

Attributes

default[R]

Returns the first object which is set as the default, or the first object if none are set as the default. @return [IndexedObject]

Public Class Methods

from_xml(nodes) click to toggle source
# File lib/saml2/indexed_object.rb, line 43
def self.from_xml(nodes)
  new(nodes.map do |node|
        name.split("::")[1..-2].inject(SAML2) do |mod, klass|
          mod.const_get(klass)
        end.from_xml(node)
      end).freeze
end
new(objects = nil) click to toggle source
Calls superclass method
# File lib/saml2/indexed_object.rb, line 51
def initialize(objects = nil)
  super()
  replace(objects.sort_by { |object| object.index || 0 }) if objects
  re_index
end

Public Instance Methods

<<(value) click to toggle source
Calls superclass method
# File lib/saml2/indexed_object.rb, line 65
def <<(value)
  super
  re_index
end
[](index) click to toggle source
# File lib/saml2/indexed_object.rb, line 57
def [](index)
  @index[index]
end
resolve(index) click to toggle source
# File lib/saml2/indexed_object.rb, line 61
def resolve(index)
  index ? self[index] : default
end

Protected Instance Methods

re_index() click to toggle source
# File lib/saml2/indexed_object.rb, line 72
def re_index
  last_index = -1
  @index = {}
  each do |object|
    object.index ||= last_index + 1
    last_index = object.index
    @index[object.index] = object
  end
  @default = find(&:default?) || first
end