Class: IssueBeaver::Models::GithubIssueRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/issue_beaver/models/github_issue_repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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,  = nil, password = nil, default_attributes = {})
  @repo = repo
  @login = 
  @password = password
  @default_attributes = Hashie::Mash.new(default_attributes)
end

Instance Attribute Details

#default_attributesObject (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

#repoObject (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

#allObject



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|
      {@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
    {@client.create_issue(@repo, attrs.title, attrs.body, attrs.only(:state, :labels, :assignee))}
  end
end

#firstObject



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
    {@client.update_issue(@repo, number, attrs.title, attrs.body, attrs.only(:state, :labels, :assignee))}
  end
end