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
79 80 81 |
# File 'lib/reactor/cm/user.rb', line 79 def initialize(name = nil) @login = name end |
Class Method Details
.all(match = nil) ⇒ Object
87 88 89 |
# File 'lib/reactor/cm/user.rb', line 87 def self.all(match = nil) self.where("userText", match) end |
Instance Method Details
#email ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/reactor/cm/user.rb', line 149 def email val = self.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, self.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
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/reactor/cm/user.rb', line 117 def val = self.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, self.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
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/reactor/cm/user.rb', line 133 def groups val = self.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, self.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
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/reactor/cm/user.rb', line 91 def has_password?(password) request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, self.class.primary_key, self.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
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/reactor/cm/user.rb', line 102 def is_root? request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, self.class.primary_key, self.login) xml.get_key_tag!(base_name, 'isSuperUser') end response = request.execute! response.xpath('//isSuperUser/text()') == '1' end |
#language ⇒ Object
113 114 115 |
# File 'lib/reactor/cm/user.rb', line 113 def language Reactor::Cm::Language.get(self.login) end |
#name ⇒ Object
83 84 85 |
# File 'lib/reactor/cm/user.rb', line 83 def name self.login end |
#real_name ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/reactor/cm/user.rb', line 165 def real_name val = self.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, self.login) xml.get_key_tag!(base_name, xml_attribute.name) end response = request.execute! self.class.response_handler.get(response, xml_attribute) end |