Class: Gitlab::Git::Patches::Collection
- Inherits:
-
Object
- Object
- Gitlab::Git::Patches::Collection
- Defined in:
- lib/gitlab/git/patches/collection.rb
Constant Summary collapse
- MAX_PATCH_SIZE =
2.megabytes
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(one_or_more_patches) ⇒ Collection
constructor
A new instance of Collection.
-
#size ⇒ Object
rubocop: disable CodeReuse/ActiveRecord ‘@patches` is not an `ActiveRecord` relation, but an `Enumerable` We’re using sum from ‘ActiveSupport`.
- #valid_size? ⇒ Boolean
Constructor Details
#initialize(one_or_more_patches) ⇒ Collection
Returns a new instance of Collection.
9 10 11 12 13 |
# File 'lib/gitlab/git/patches/collection.rb', line 9 def initialize(one_or_more_patches) @patches = Array(one_or_more_patches).map do |patch_content| Gitlab::Git::Patches::Patch.new(patch_content) end end |
Instance Method Details
#content ⇒ Object
15 16 17 |
# File 'lib/gitlab/git/patches/collection.rb', line 15 def content @patches.map(&:content).join("\n") end |
#size ⇒ Object
rubocop: disable CodeReuse/ActiveRecord ‘@patches` is not an `ActiveRecord` relation, but an `Enumerable` We’re using sum from ‘ActiveSupport`
26 27 28 |
# File 'lib/gitlab/git/patches/collection.rb', line 26 def size @size ||= @patches.sum(&:size) end |
#valid_size? ⇒ Boolean
19 20 21 |
# File 'lib/gitlab/git/patches/collection.rb', line 19 def valid_size? size < MAX_PATCH_SIZE end |