class JSON::SchemaDsl::Renderers::Filter

Filters out properties that are either used internally only or which are redundant (I.e. set to nil).

Constants

INVISIBLES

Public Instance Methods

visit(entity) click to toggle source

Filters out properties that are either used internally only or which are redundant (I.e. set to nil).

# File lib/json/schema_dsl/renderers/filter.rb, line 13
def visit(entity)
  traverse(filter(entity))
end

Private Instance Methods

filter(entity) click to toggle source
# File lib/json/schema_dsl/renderers/filter.rb, line 19
def filter(entity)
  entity
    .except(*(INVISIBLES + INVISIBLES.map(&:underscore).map(&:to_sym)))
    .transform_values { |v| presence_of(v, preserve: [false]) }
    .compact
end
presence_of(obj, preserve: []) click to toggle source
# File lib/json/schema_dsl/renderers/filter.rb, line 26
def presence_of(obj, preserve: [])
  return obj if preserve.include? obj

  obj.presence
end