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.



51
52
53
54
55
# 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

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
46
47
48
49
# 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

Instance Method Details

#<<(value) ⇒ Object



65
66
67
68
# File 'lib/saml2/indexed_object.rb', line 65

def <<(value)
  super
  re_index
end

#[](index) ⇒ Object



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

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

#resolve(index) ⇒ Object



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

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