Class: SAML2::IndexedObject::Array
- Inherits:
-
Array
- Object
- Array
- SAML2::IndexedObject::Array
- Defined in:
- lib/saml2/indexed_object.rb
Overview
Keeps an Array of SAML2::IndexedObjects in their indexed order.
Instance Attribute Summary collapse
-
#default ⇒ IndexedObject
readonly
Returns the first object which is set as the default, or the first object if none are set as the default.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(value) ⇒ Object
- #[](index) ⇒ Object
-
#initialize(objects = nil) ⇒ Array
constructor
A new instance of Array.
- #resolve(index) ⇒ Object
Constructor Details
#initialize(objects = nil) ⇒ Array
Returns a new instance of Array.
53 54 55 56 57 |
# 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 |
Instance Attribute Details
#default ⇒ IndexedObject (readonly)
Returns the first object which is set as the default, or the first object if none are set as the default.
45 46 47 |
# File 'lib/saml2/indexed_object.rb', line 45 def default @default end |
Class Method Details
.from_xml(nodes) ⇒ Object
47 48 49 50 51 |
# 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 |
Instance Method Details
#<<(value) ⇒ Object
67 68 69 70 |
# File 'lib/saml2/indexed_object.rb', line 67 def <<(value) super re_index end |
#[](index) ⇒ Object
59 60 61 |
# File 'lib/saml2/indexed_object.rb', line 59 def [](index) @index[index] end |
#resolve(index) ⇒ Object
63 64 65 |
# File 'lib/saml2/indexed_object.rb', line 63 def resolve(index) index ? self[index] : default end |