Class: HubLink::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/hub_link/batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Batch

Returns a new instance of Batch.



7
8
9
# File 'lib/hub_link/batch.rb', line 7

def initialize(options = {})
  @options = options.compact
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/hub_link/batch.rb', line 5

def options
  @options
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/hub_link/batch.rb', line 11

def empty?
  results.empty?
end

#fetch(resource) ⇒ Object



15
16
17
# File 'lib/hub_link/batch.rb', line 15

def fetch(resource)
  public_send(resource)
end

#pull_requestsObject



19
20
21
22
23
# File 'lib/hub_link/batch.rb', line 19

def pull_requests
  log "Fetching pull requests" do
    pull_request_results.find_all(&:pull_request?).map(&:to_h)
  end
end

#review_requestsObject



31
32
33
34
35
# File 'lib/hub_link/batch.rb', line 31

def review_requests
  log "Fetching review requests" do
    pull_request_results.flat_map(&:review_requests).map(&:to_h)
  end
end

#reviewsObject



25
26
27
28
29
# File 'lib/hub_link/batch.rb', line 25

def reviews
  log "Fetching reviews" do
    pull_request_results.flat_map(&:reviews).map(&:to_h)
  end
end