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.
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
#default ⇒ IndexedObject (readonly)
Returns the first object which is set as the default, or the first object if none are set as the default.
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 |