Class: Phabricator::Project
- Inherits:
-
Object
- Object
- Phabricator::Project
- Defined in:
- lib/phabricator/project.rb
Constant Summary collapse
- @@cached_projects =
{}
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#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) ⇒ Project
constructor
A new instance of Project.
Constructor Details
#initialize(attributes) ⇒ Project
Returns a new instance of Project.
27 28 29 30 31 |
# File 'lib/phabricator/project.rb', line 27 def initialize(attributes) @id = attributes['id'] @phid = attributes['phid'] @name = attributes['name'] end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/phabricator/project.rb', line 7 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/phabricator/project.rb', line 8 def name @name end |
#phid ⇒ Object (readonly)
Returns the value of attribute phid.
7 8 9 |
# File 'lib/phabricator/project.rb', line 7 def phid @phid end |
Class Method Details
.find_by_name(name) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/phabricator/project.rb', line 19 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_projects[name] @@cached_projects[name] end |
.populate_all ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/phabricator/project.rb', line 10 def self.populate_all response = JSON.parse(client.request(:post, 'project.query')) response['result'].each do |phid, data| project = Project.new(data) @@cached_projects[project.name] = project end end |