Class: IssueBeaver::Models::GithubIssueRepository
- Inherits:
-
Object
- Object
- IssueBeaver::Models::GithubIssueRepository
- Defined in:
- lib/issue_beaver/models/github_issue_repository.rb
Instance Attribute Summary collapse
-
#default_attributes ⇒ Object
readonly
Returns the value of attribute default_attributes.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #all ⇒ Object
- #create(attrs) ⇒ Object
- #first ⇒ Object
-
#initialize(repo, login = nil, password = nil, default_attributes = {}) ⇒ GithubIssueRepository
constructor
A new instance of GithubIssueRepository.
- #update(number, attrs) ⇒ Object
Constructor Details
#initialize(repo, login = nil, password = nil, default_attributes = {}) ⇒ GithubIssueRepository
Returns a new instance of GithubIssueRepository.
10 11 12 13 14 15 |
# File 'lib/issue_beaver/models/github_issue_repository.rb', line 10 def initialize(repo, login = nil, password = nil, default_attributes = {}) @repo = repo @login = login @password = password @default_attributes = Hashie::Mash.new(default_attributes) end |
Instance Attribute Details
#default_attributes ⇒ Object (readonly)
Returns the value of attribute default_attributes.
17 18 19 |
# File 'lib/issue_beaver/models/github_issue_repository.rb', line 17 def default_attributes @default_attributes end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
17 18 19 |
# File 'lib/issue_beaver/models/github_issue_repository.rb', line 17 def repo @repo end |
Instance Method Details
#all ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/issue_beaver/models/github_issue_repository.rb', line 20 def all @fetched_issues ||= Enumerator.new do |y| with_login{@client.list_issues(@repo)}.each do |i| y << i end end.memoizing.lazy @local_issues ||= [] @issues ||= @fetched_issues.merge_right(@local_issues, :number).lazy end |
#create(attrs) ⇒ Object
44 45 46 47 48 |
# File 'lib/issue_beaver/models/github_issue_repository.rb', line 44 def create(attrs) sync_cache do with_login{@client.create_issue(@repo, attrs.title, attrs.body, attrs.only(:state, :labels, :assignee))} end end |
#first ⇒ Object
32 33 34 |
# File 'lib/issue_beaver/models/github_issue_repository.rb', line 32 def first all.at(0) end |
#update(number, attrs) ⇒ Object
37 38 39 40 41 |
# File 'lib/issue_beaver/models/github_issue_repository.rb', line 37 def update(number, attrs) sync_cache do with_login{@client.update_issue(@repo, number, attrs.title, attrs.body, attrs.only(:state, :labels, :assignee))} end end |