Sha256: f8a91b7e13104095df7537c827fa89c226bae1e482852737f12487fc2e835d8e
Contents?: true
Size: 889 Bytes
Versions: 2
Compression:
Stored size: 889 Bytes
Contents
require 'json' require_relative 'base' module RubyTerraform module Options module Types class Standard < Base def apply(builder) if value.respond_to?(:keys) apply_hash(builder) elsif value.respond_to?(:each) apply_array(builder) else builder.with_option(name, value) end end private def apply_hash(builder) builder.with_repeated_option( name, value.map do |hash_key, hash_value| "'#{hash_key}=#{as_string(hash_value)}'" end, separator: ' ' ) end def apply_array(builder) builder.with_repeated_option(name, value) end def as_string(value) value.is_a?(String) ? value : JSON.generate(value) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-terraform-0.65.0.pre.8 | lib/ruby_terraform/options/types/standard.rb |
ruby-terraform-0.65.0.pre.7 | lib/ruby_terraform/options/types/standard.rb |