Sha256: 07161b4273f1d8eb139cc1b7a0b61aa8df7cf0e2e21fc803c95130cb665baed7

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 KB

Contents

class Jets::Resource
  extend Memoist

  attr_reader :definition, :replacements
  def initialize(definition, replacements={})
    @definition = definition
    @replacements = replacements
  end

  def template
    standarize(definition)
  end
  memoize :template

  # CloudFormation Resources reference: https://amzn.to/2NKg6ip
  def standarize(*definition)
    Standardizer.new(definition).template
  end

  def logical_id
    id = template.keys.first
    # replace possible {namespace} in the logical id
    id = replacer.replace_value(id)
    Jets::Camelizer.camelize(id)
  end

  def type
    attributes['Type']
  end

  def properties
    attributes['Properties']
  end

  def attributes
    attributes = template.values.first
    attributes = replacer.replace_placeholders(attributes)
    Jets::Camelizer.transform(attributes)
  end

  def parameters
    {}
  end

  def outputs
    {}
  end

  def replacer
    Replacer.new(replacements)
  end
  memoize :replacer

  def permission
    Permission.new(replacements, self)
  end
  memoize :permission
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
jets-1.9.28 lib/jets/resource.rb
jets-1.9.27 lib/jets/resource.rb
jets-1.9.26 lib/jets/resource.rb
jets-1.9.25 lib/jets/resource.rb
jets-1.9.24 lib/jets/resource.rb
jets-1.9.23 lib/jets/resource.rb
jets-1.9.22 lib/jets/resource.rb
jets-1.9.21 lib/jets/resource.rb
jets-1.9.20 lib/jets/resource.rb
jets-1.9.19 lib/jets/resource.rb
jets-1.9.18 lib/jets/resource.rb
jets-1.9.17 lib/jets/resource.rb
jets-1.9.16 lib/jets/resource.rb
jets-1.9.15 lib/jets/resource.rb
jets-1.9.14 lib/jets/resource.rb
jets-1.9.13 lib/jets/resource.rb
jets-1.9.12 lib/jets/resource.rb
jets-1.9.11 lib/jets/resource.rb
jets-1.9.10 lib/jets/resource.rb
jets-1.9.9 lib/jets/resource.rb