Module: AwsUtil
- Defined in:
- lib/util/AwsUtil.rb
Class Method Summary collapse
-
.array_or_nil(arr) ⇒ Object
Public: Static method that returns nil if an array is empty.
-
.aws_array(arr) ⇒ Object
Public: Static method that converts an array to an object that can be used in the AWS API (with quantity and items).
- .list_paged_results ⇒ Object
Class Method Details
.array_or_nil(arr) ⇒ Object
Public: Static method that returns nil if an array is empty
arr - an array to conver
Returns nil if the array is empty, or the original array otherwise
27 28 29 30 31 32 33 |
# File 'lib/util/AwsUtil.rb', line 27 def self.array_or_nil(arr) if arr.nil? || arr.empty? nil else arr end end |
.aws_array(arr) ⇒ Object
Public: Static method that converts an array to an object that can be used in the AWS API (with quantity and items)
arr - the array to convert
Returns an object with quantity and items
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/util/AwsUtil.rb', line 8 def self.aws_array(arr) if arr.nil? || arr.empty? { quantity: 0, items: nil } else { quantity: arr.size, items: arr } end end |
.list_paged_results ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/util/AwsUtil.rb', line 35 def self.list_paged_results more = true marker = nil all_results = [] while more do (result, more, marker) = yield(marker) all_results += result end all_results end |