Class: ParamsProcessor::ParamDoc

Inherits:
HashWithIndifferentAccess
  • Object
show all
Defined in:
lib/params_processor/param_doc.rb

Instance Method Summary collapse

Instance Method Details

#combinedObject



28
29
30
# File 'lib/params_processor/param_doc.rb', line 28

def combined
  { all_of: all_of, one_of: one_of, any_of: any_of, not: not_be }.keep_if { |_k, v| !v.nil? }
end

#combined?Boolean

Returns:

  • (Boolean)


32
# File 'lib/params_processor/param_doc.rb', line 32

def combined?; combined.present? end

#combined_modesObject



34
# File 'lib/params_processor/param_doc.rb', line 34

def combined_modes; combined.keys end

#doced_permit?Boolean

Returns:

  • (Boolean)


38
# File 'lib/params_processor/param_doc.rb', line 38

def doced_permit?; permit? || not_permit? end

#rangeObject

Interfaces for directly taking the processed info what we focus on.



8
9
10
11
12
13
14
15
16
# File 'lib/params_processor/param_doc.rb', line 8

def range
  return if (schema.keys & %w[ minimum maximum ]).blank?
  {
      min: schema[:minimum] || -Float::INFINITY,
      max: schema[:maximum] || Float::INFINITY,
      should_neq_min?: schema[:exclusiveMinimum] || false,
      should_neq_max?: schema[:exclusiveMaximum] || false
  }
end

#real_nameObject



36
# File 'lib/params_processor/param_doc.rb', line 36

def real_name; as || name end

#sizeObject



18
19
20
21
22
23
24
25
26
# File 'lib/params_processor/param_doc.rb', line 18

def size
  return if (schema.keys & %w[ minItems maxItems minLength maxLength ]).blank?
  size = if type.in? %w[ array object ]
           [schema[:minItems], schema[:maxItems]]
         else
           [schema[:minLength], schema[:maxLength]]
         end
  { min: size[0] || 0, max: size[1] || Float::INFINITY }
end