Class: Gitlab::Utils::DeepSize
- Inherits:
-
Object
- Object
- Gitlab::Utils::DeepSize
- Defined in:
- lib/gitlab/utils/deep_size.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
- TooMuchDataError =
Class.new(Error)
- DEFAULT_MAX_SIZE =
1.megabyte
- DEFAULT_MAX_DEPTH =
100
Instance Method Summary collapse
-
#initialize(root, max_size: DEFAULT_MAX_SIZE, max_depth: DEFAULT_MAX_DEPTH) ⇒ DeepSize
constructor
A new instance of DeepSize.
- #valid? ⇒ Boolean
Constructor Details
#initialize(root, max_size: DEFAULT_MAX_SIZE, max_depth: DEFAULT_MAX_DEPTH) ⇒ DeepSize
Returns a new instance of DeepSize.
14 15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/utils/deep_size.rb', line 14 def initialize(root, max_size: DEFAULT_MAX_SIZE, max_depth: DEFAULT_MAX_DEPTH) @root = root @max_size = max_size || DEFAULT_MAX_SIZE @max_depth = max_depth || DEFAULT_MAX_DEPTH @size = 0 @depth = 0 evaluate end |
Instance Method Details
#valid? ⇒ Boolean
24 25 26 |
# File 'lib/gitlab/utils/deep_size.rb', line 24 def valid? !too_big? && !too_deep? end |