Define constants only if not defined yet and freeze them
Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
53a1d705fe
commit
2e9f03e514
2 changed files with 7 additions and 7 deletions
|
@ -12,11 +12,11 @@ class Commit
|
|||
|
||||
attr_accessor :project
|
||||
|
||||
DIFF_SAFE_LINES = Gitlab::Git::DiffCollection::DEFAULT_LIMITS[:max_lines]
|
||||
DIFF_SAFE_LINES ||= Gitlab::Git::DiffCollection::DEFAULT_LIMITS[:max_lines]
|
||||
|
||||
# Commits above this size will not be rendered in HTML
|
||||
DIFF_HARD_LIMIT_FILES = 1000 unless defined?(DIFF_HARD_LIMIT_FILES)
|
||||
DIFF_HARD_LIMIT_LINES = 50000 unless defined?(DIFF_HARD_LIMIT_LINES)
|
||||
DIFF_HARD_LIMIT_FILES ||= 1000
|
||||
DIFF_HARD_LIMIT_LINES ||= 50000
|
||||
|
||||
class << self
|
||||
def decorate(commits, project)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class FileSizeValidator < ActiveModel::EachValidator
|
||||
MESSAGES = { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze
|
||||
CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze
|
||||
MESSAGES ||= { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze
|
||||
CHECKS ||= { is: :==, minimum: :>=, maximum: :<= }.freeze
|
||||
|
||||
DEFAULT_TOKENIZER = lambda { |value| value.split(//) }
|
||||
RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long]
|
||||
DEFAULT_TOKENIZER ||= -> (value) { value.split(//) }.freeze
|
||||
RESERVED_OPTIONS ||= [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long].freeze
|
||||
|
||||
def initialize(options)
|
||||
if range = (options.delete(:in) || options.delete(:within))
|
||||
|
|
Loading…
Reference in a new issue