Class: LUSI::API::Enrolment::EnrolmentBase Abstract
- Inherits:
-
Object
- Object
- LUSI::API::Enrolment::EnrolmentBase
- Extended by:
- Core::Endpoint
- Defined in:
- lib/lusi_api/enrolment.rb
Overview
Subclasses must define the lusi_ws_* endpoint methods and additional attributes
The abstract base class for enrolment classes
Direct Known Subclasses
Instance Attribute Summary collapse
-
#enrolment_role ⇒ LUSI::API::Enrolment::EnrolmentRole?
The role that members have against this enrolment.
-
#identity ⇒ LUSI::API::Enrolment::EnrolmentIdentity
The identity of the subject (person) of the enrolment.
-
#is_current_enrolment ⇒ Boolean?
True if the enrolment is current, false otherwise.
-
#is_current_identity ⇒ Boolean?
True if the member’s identity is current, false otherwise.
-
#username ⇒ String?
The username of the subject (person) of the enrolment.
Class Method Summary collapse
-
.get_instance(api, lookup = nil, current_only: nil, **kwargs) {|obj| ... } ⇒ Object
Returns an array of instances matching the specified search criteria.
- .lusi_ws_path ⇒ Object
Instance Method Summary collapse
-
#initialize(xml = nil, lookup = nil, enrolment_role: nil, identity: nil, is_current_enrolment: nil, is_current_identity: nil, username: nil) ⇒ void
constructor
Initalises a new Enrolment instance.
-
#lookup_indices ⇒ Array<Symbol>
Returns the lookup indices supported by this enrolment type.
-
#lookup_key(index = nil) ⇒ Object
Returns the value to be used as a key for the specified lookup index.
Methods included from Core::Endpoint
lusi_ws_endpoint, lusi_ws_method, lusi_ws_path, lusi_ws_xml_root
Constructor Details
#initialize(xml = nil, lookup = nil, enrolment_role: nil, identity: nil, is_current_enrolment: nil, is_current_identity: nil, username: nil) ⇒ void
Initalises a new Enrolment instance
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/lusi_api/enrolment.rb', line 65 def initialize(xml = nil, lookup = nil, enrolment_role: nil, identity: nil, is_current_enrolment: nil, is_current_identity: nil, username: nil) is_current_enrolment = is_current_enrolment.nil? || is_current_enrolment ? true : false is_current_identity = is_current_identity.nil? || is_current_identity ? true : false @enrolment_role = EnrolmentRole.new(LUSI::API::Core::XML.xml_at(xml, 'xmlns:EnrolmentRole', enrolment_role), lookup) @identity = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Identity', identity) @is_current_enrolment = LUSI::API::Core::XML.xml_boolean_at(xml, 'xmlns:IsCurrentEnrolment', is_current_enrolment) @is_current_identity = LUSI::API::Core::XML.xml_boolean_at(xml, 'xmlns:IsCurrentIdentity', is_current_identity) @username = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Username', username) end |
Instance Attribute Details
#enrolment_role ⇒ LUSI::API::Enrolment::EnrolmentRole?
Returns the role that members have against this enrolment.
38 39 40 |
# File 'lib/lusi_api/enrolment.rb', line 38 def enrolment_role @enrolment_role end |
#identity ⇒ LUSI::API::Enrolment::EnrolmentIdentity
Returns the identity of the subject (person) of the enrolment.
42 43 44 |
# File 'lib/lusi_api/enrolment.rb', line 42 def identity @identity end |
#is_current_enrolment ⇒ Boolean?
Returns true if the enrolment is current, false otherwise.
46 47 48 |
# File 'lib/lusi_api/enrolment.rb', line 46 def is_current_enrolment @is_current_enrolment end |
#is_current_identity ⇒ Boolean?
Returns true if the member’s identity is current, false otherwise.
50 51 52 |
# File 'lib/lusi_api/enrolment.rb', line 50 def is_current_identity @is_current_identity end |
#username ⇒ String?
Returns the username of the subject (person) of the enrolment.
54 55 56 |
# File 'lib/lusi_api/enrolment.rb', line 54 def username @username end |
Class Method Details
.get_instance(api, lookup = nil, current_only: nil, **kwargs) {|obj| ... } ⇒ Object
Returns an array of instances matching the specified search criteria
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/lusi_api/enrolment.rb', line 84 def self.get_instance(api, lookup = nil, current_only: nil, **kwargs) current_only = current_only.nil? || current_only ? true : false if current_only # Filter nodes which have current enrolments and user identities filter = Proc.new do |node| LUSI::API::Core::XML.xml_boolean_at(node, 'xmlns:IsCurrentEnrolment', false) && LUSI::API::Core::XML.xml_boolean_at(node, 'xmlns:IsCurrentIdentity', false) end else filter = nil end params = self.get_instance_params(**kwargs) xml = api.call(self.lusi_ws_path, self.lusi_ws_endpoint, self.lusi_ws_method, **params) result = LUSI::API::Core::XML.xml(xml, "xmlns:#{self.lusi_ws_xml_root}", filter: filter) do |m| obj = self.new(m, lookup) yield(obj) if block_given? obj end # Return the array of instances result end |
.lusi_ws_path ⇒ Object
128 129 130 |
# File 'lib/lusi_api/enrolment.rb', line 128 def self.lusi_ws_path 'UserDetails' end |
Instance Method Details
#lookup_indices ⇒ Array<Symbol>
Returns the lookup indices supported by this enrolment type
108 109 110 |
# File 'lib/lusi_api/enrolment.rb', line 108 def lookup_indices [:identity, :role, :username] end |
#lookup_key(index = nil) ⇒ Object
Returns the value to be used as a key for the specified lookup index
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/lusi_api/enrolment.rb', line 114 def lookup_key(index = nil) case index when :identity self.identity when :role self.enrolment_role ? self.enrolment_role.identity : nil when :username self.username else nil end end |