Class: Reactor::Cm::User
- Inherits:
-
Object
- Object
- Reactor::Cm::User
- Extended by:
- WhereQuery
- Includes:
- XmlAttributes
- Defined in:
- lib/reactor/cm/user.rb
Defined Under Namespace
Classes: Internal
Class Method Summary collapse
Instance Method Summary collapse
- #email ⇒ Object
- #global_permissions ⇒ Object
- #groups ⇒ Object
- #has_password?(password) ⇒ Boolean
-
#initialize(name = nil) ⇒ User
constructor
A new instance of User.
- #is_root? ⇒ Boolean
- #language ⇒ Object
- #name ⇒ Object
- #real_name ⇒ Object
Methods included from WhereQuery
Constructor Details
#initialize(name = nil) ⇒ User
Returns a new instance of User.
74 75 76 |
# File 'lib/reactor/cm/user.rb', line 74 def initialize(name = nil) @login = name end |
Class Method Details
.all(match = nil) ⇒ Object
82 83 84 |
# File 'lib/reactor/cm/user.rb', line 82 def self.all(match = nil) where("userText", match) end |
.base_name ⇒ Object
182 183 184 |
# File 'lib/reactor/cm/user.rb', line 182 def self.base_name "userProxy" end |
Instance Method Details
#email ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/reactor/cm/user.rb', line 144 def email val = instance_variable_get(:@email) return val unless val.nil? xml_attribute = self.class.xml_attribute(:email) request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, self.class.primary_key, login) xml.get_key_tag!(base_name, xml_attribute.name) end response = request.execute! self.class.response_handler.get(response, xml_attribute) end |
#global_permissions ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/reactor/cm/user.rb', line 112 def val = instance_variable_get(:@global_permissions) return val unless val.nil? xml_attribute = self.class.xml_attribute(:global_permissions) request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, self.class.primary_key, login) xml.get_key_tag!(base_name, xml_attribute.name) end response = request.execute! self.class.response_handler.get(response, xml_attribute) end |
#groups ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/reactor/cm/user.rb', line 128 def groups val = instance_variable_get(:@groups) return val unless val.nil? xml_attribute = self.class.xml_attribute(:groups) request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, self.class.primary_key, login) xml.get_key_tag!(base_name, xml_attribute.name) end response = request.execute! self.class.response_handler.get(response, xml_attribute) end |
#has_password?(password) ⇒ Boolean
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/reactor/cm/user.rb', line 86 def has_password?(password) request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, self.class.primary_key, login) xml.get_tag!(base_name) do |xml3| xml3.tag!("hasPassword", password: password) end end response = request.execute! response.xpath("//hasPassword/text()") == "1" end |
#is_root? ⇒ Boolean
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/reactor/cm/user.rb', line 97 def is_root? request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, self.class.primary_key, login) xml.get_key_tag!(base_name, "isSuperUser") end response = request.execute! response.xpath("//isSuperUser/text()") == "1" end |
#language ⇒ Object
108 109 110 |
# File 'lib/reactor/cm/user.rb', line 108 def language Reactor::Cm::Language.get(login) end |
#name ⇒ Object
78 79 80 |
# File 'lib/reactor/cm/user.rb', line 78 def name login end |
#real_name ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/reactor/cm/user.rb', line 160 def real_name val = instance_variable_get(:@real_name) return val unless val.nil? xml_attribute = self.class.xml_attribute(:real_name) request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, self.class.primary_key, login) xml.get_key_tag!(base_name, xml_attribute.name) end response = request.execute! self.class.response_handler.get(response, xml_attribute) end |