Sha256: d2b9f3b86f935d3ee2205ac775d0dcb6123b3880da4519097563018bf42f4bad

Contents?: true

Size: 1.76 KB

Versions: 20

Compression:

Stored size: 1.76 KB

Contents

class Jets::Resource
  extend Memoist

  autoload :ApiGateway, 'jets/resource/api_gateway'
  autoload :Associated, 'jets/resource/associated'
  autoload :Base, 'jets/resource/base'
  autoload :ChildStack, 'jets/resource/child_stack'
  autoload :Config, 'jets/resource/config'
  autoload :Events, 'jets/resource/events'
  autoload :Iam, 'jets/resource/iam'
  autoload :Iot, 'jets/resource/iot'
  autoload :Lambda, 'jets/resource/lambda'
  autoload :Logs, 'jets/resource/logs'
  autoload :Permission, 'jets/resource/permission'
  autoload :Replacer, 'jets/resource/replacer'
  autoload :Route53, 'jets/resource/route53'
  autoload :S3, 'jets/resource/s3'
  autoload :Sns, 'jets/resource/sns'
  autoload :Sqs, 'jets/resource/sqs'
  autoload :Standardizer, 'jets/resource/standardizer'

  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

20 entries across 20 versions & 1 rubygems

Version Path
jets-1.9.7 lib/jets/resource.rb
jets-1.9.6 lib/jets/resource.rb
jets-1.9.5 lib/jets/resource.rb
jets-1.9.4 lib/jets/resource.rb
jets-1.9.3 lib/jets/resource.rb
jets-1.9.2 lib/jets/resource.rb
jets-1.9.1 lib/jets/resource.rb
jets-1.9.0 lib/jets/resource.rb
jets-1.8.14 lib/jets/resource.rb
jets-1.8.13 lib/jets/resource.rb
jets-1.8.12 lib/jets/resource.rb
jets-1.8.11 lib/jets/resource.rb
jets-1.8.10 lib/jets/resource.rb
jets-1.8.9 lib/jets/resource.rb
jets-1.8.8 lib/jets/resource.rb
jets-1.8.7 lib/jets/resource.rb
jets-1.8.6 lib/jets/resource.rb
jets-1.8.5 lib/jets/resource.rb
jets-1.8.4 lib/jets/resource.rb
jets-1.8.3 lib/jets/resource.rb