Class: BBC::Cosmos::Tools::Types::BaseType

Inherits:
Object
  • Object
show all
Defined in:
lib/bbc/cosmos/tools/types/base_type.rb

Direct Known Subclasses

Json, Yaml

Instance Method Summary collapse

Constructor Details

#initialize(id, options, config) ⇒ BaseType

Returns a new instance of BaseType.



9
10
11
12
13
# File 'lib/bbc/cosmos/tools/types/base_type.rb', line 9

def initialize(id, options, config)
  @id      = id
  @options = options
  @config  = config
end

Instance Method Details

#generate_data(to_json = false) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/bbc/cosmos/tools/types/base_type.rb', line 15

def generate_data(to_json = false)
  if valid_component_and_stack
    get_parameters.each do |key, value|
      if data.has_key?("Parameters") && data["Parameters"][key]
        data["Parameters"][key]["Default"] = value
      end
    end
    to_json ? JSON.pretty_generate(data) : data
  end
end