Module: BWStatusBoardAPI::Client::Helpers

Included in:
Boards, Environments, Environments::Services, Metrics
Defined in:
lib/bw_status_board_api/client/helpers/filter.rb

Overview

Helpers module

Instance Method Summary collapse

Instance Method Details

#filter(response, summary = false, key = nil, value = nil) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/bw_status_board_api/client/helpers/filter.rb', line 5

def filter(response, summary = false, key = nil, value = nil)
  response.each_with_object([]) do |hash, array|
    if value.nil? || hash[key] == value
      summary ? array << hash['name'] : array << hash
    end
  end
end