Class: Prmd::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/prmd/core/generator.rb

Overview

Schema generator

Instance Method Summary collapse

Constructor Details

#initialize(properties = {}) ⇒ Generator

Returns a new instance of Generator.

Parameters:

  • properties (Hash<Symbol, Object>) (defaults to: {})


10
11
12
13
14
# File 'lib/prmd/core/generator.rb', line 10

def initialize(properties = {})
  @properties = properties
  @base = properties.fetch(:base, {})
  @template = properties.fetch(:template)
end

Instance Method Details

#generate(options = {}) ⇒ Object

Parameters:

  • options (Hash<Symbol, Object>) (defaults to: {})


18
19
20
21
22
23
24
25
# File 'lib/prmd/core/generator.rb', line 18

def generate(options = {})
  res = @template.result(options)
  resource_schema = JSON.parse(res)
  schema = Prmd::Schema.new
  schema.merge!(@base)
  schema.merge!(resource_schema)
  schema
end