Class: Phabricator::User
- Inherits:
-
Object
- Object
- Phabricator::User
- Defined in:
- lib/phabricator/user.rb
Constant Summary collapse
- @@cached_users =
{}
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#phid ⇒ Object
readonly
Returns the value of attribute phid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(attributes) ⇒ User
Returns a new instance of User.
28 29 30 31 |
# File 'lib/phabricator/user.rb', line 28 def initialize(attributes) @phid = attributes['phid'] @name = attributes['userName'] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/phabricator/user.rb', line 8 def name @name end |
#phid ⇒ Object (readonly)
Returns the value of attribute phid.
7 8 9 |
# File 'lib/phabricator/user.rb', line 7 def phid @phid end |
Class Method Details
.find_by_name(name) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/phabricator/user.rb', line 20 def self.find_by_name(name) # Re-populate if we couldn't find it in the cache (this applies to # if the cache is empty as well). populate_all unless @@cached_users[name] @@cached_users[name] end |
.populate_all ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/phabricator/user.rb', line 10 def self.populate_all response = JSON.parse(client.request(:post, 'user.query')) response['result'].each do |data| user = User.new(data) @@cached_users[user.name] = user end end |