Sha256: 4febb17072a567611b8a33a1f3d9293a5a81c264e91545c751909144dd8f2e3d

Contents?: true

Size: 1.61 KB

Versions: 32

Compression:

Stored size: 1.61 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 :Function, 'jets/resource/function'
  autoload :Iam, 'jets/resource/iam'
  autoload :Permission, 'jets/resource/permission'
  autoload :Replacer, 'jets/resource/replacer'
  autoload :S3, 'jets/resource/s3'
  autoload :Sns, 'jets/resource/sns'
  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

32 entries across 32 versions & 1 rubygems

Version Path
jets-1.1.5 lib/jets/resource.rb
jets-1.1.4 lib/jets/resource.rb
jets-1.1.3 lib/jets/resource.rb
jets-1.1.2 lib/jets/resource.rb
jets-1.1.1 lib/jets/resource.rb
jets-1.1.0 lib/jets/resource.rb
jets-1.0.18 lib/jets/resource.rb
jets-1.0.17 lib/jets/resource.rb
jets-1.0.16 lib/jets/resource.rb
jets-1.0.15 lib/jets/resource.rb
jets-1.0.13 lib/jets/resource.rb
jets-1.0.12 lib/jets/resource.rb
jets-1.0.11 lib/jets/resource.rb
jets-1.0.10 lib/jets/resource.rb
jets-1.0.9 lib/jets/resource.rb
jets-1.0.8 lib/jets/resource.rb
jets-1.0.7 lib/jets/resource.rb
jets-1.0.6 lib/jets/resource.rb
jets-1.0.5 lib/jets/resource.rb
jets-1.0.4 lib/jets/resource.rb