Class: JSON::SchemaDsl::Renderers::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/json/schema_dsl/renderers/base.rb

Overview

This class is abstract.

The abstract base renderer that provides common behaviour to all renderers like the depth-first-traversal and access to the scope.

Direct Known Subclasses

Alias, Desugar, Filter, Multiplexer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope) ⇒ Base

Returns a new instance of Base.

Parameters:

  • scope (Object)

    The scope used as a fallback for helper methods.



13
14
15
# File 'lib/json/schema_dsl/renderers/base.rb', line 13

def initialize(scope)
  @scope = scope
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



11
12
13
# File 'lib/json/schema_dsl/renderers/base.rb', line 11

def scope
  @scope
end

Instance Method Details

#traverse(entity) ⇒ Hash

Returns The hash-tree with all values visited.

Parameters:

  • entity (Hash)

    The entity-structure given as a tree. This method will recursively visit each value in the structure until all have been visited.

Returns:

  • (Hash)

    The hash-tree with all values visited.



21
22
23
# File 'lib/json/schema_dsl/renderers/base.rb', line 21

def traverse(entity)
  entity.transform_values { |v| step(v) }
end