class SAML2::IndexedObject::Array
Keeps an Array
of {IndexedObject}s in their +index+ed order.
Attributes
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
Source
# File lib/saml2/indexed_object.rb, line 47 def self.from_xml(nodes) new(nodes.map do |node| Object.const_get(name.rpartition("::").first, false).from_xml(node) end).freeze end
Source
# File lib/saml2/indexed_object.rb, line 53 def initialize(objects = nil) super() replace(objects.sort_by { |object| object.index || 0 }) if objects re_index end
Calls superclass method
Public Instance Methods
Source
# File lib/saml2/indexed_object.rb, line 67 def <<(value) super re_index end
Calls superclass method
Source
# File lib/saml2/indexed_object.rb, line 63 def resolve(index) index ? self[index] : default end
Protected Instance Methods
Source
# File lib/saml2/indexed_object.rb, line 74 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