Class: GithubControl::Collaborators
- Inherits:
-
Object
- Object
- GithubControl::Collaborators
- Includes:
- Enumerable
- Defined in:
- lib/github-control/collaborators.rb
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #create(user) ⇒ Object
- #delete(user) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(repository) ⇒ Collaborators
constructor
A new instance of Collaborators.
- #json_data ⇒ Object
- #loaded? ⇒ Boolean
- #set ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(repository) ⇒ Collaborators
Returns a new instance of Collaborators.
7 8 9 |
# File 'lib/github-control/collaborators.rb', line 7 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
5 6 7 |
# File 'lib/github-control/collaborators.rb', line 5 def repository @repository end |
Instance Method Details
#create(user) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/github-control/collaborators.rb', line 11 def create(user) @repository.owner.cli.post("/repos/collaborators/" \ "#{@repository.name}/add/#{user}") if loaded? set << @repository.owner.cli.user_for(user) else set end end |
#delete(user) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/github-control/collaborators.rb', line 21 def delete(user) @repository.owner.cli.post("/repos/collaborators/" \ "#{@repository.name}/remove/#{user}") if loaded? set.delete_if { |u| u.name == user } end end |
#each(&block) ⇒ Object
29 30 31 |
# File 'lib/github-control/collaborators.rb', line 29 def each(&block) set.each(&block) end |
#json_data ⇒ Object
47 48 49 50 |
# File 'lib/github-control/collaborators.rb', line 47 def json_data @repository.owner.cli.post("/repos/show/" \ "#{@repository.owner.name}/#{@repository.name}/collaborators") end |
#loaded? ⇒ Boolean
37 38 39 |
# File 'lib/github-control/collaborators.rb', line 37 def loaded? @set end |
#set ⇒ Object
41 42 43 44 45 |
# File 'lib/github-control/collaborators.rb', line 41 def set @set ||= json_data["collaborators"].map { |name| @repository.owner.cli.user_for(name) } end |
#size ⇒ Object
33 34 35 |
# File 'lib/github-control/collaborators.rb', line 33 def size set.size end |