class Dyna::DSL

Attributes

result[R]

Public Class Methods

convert(region, exported) click to toggle source
# File lib/dyna/dsl.rb, line 12
def convert(region, exported)
  Converter.convert(region, exported)
end
define(source, path) click to toggle source
# File lib/dyna/dsl.rb, line 6
def define(source, path)
  self.new(path) do
    eval(source, binding, path)
  end
end
new(path, &block) click to toggle source
# File lib/dyna/dsl.rb, line 19
def initialize(path, &block)
  @path = path
  @result = OpenStruct.new(:ddbs => {})

  @context = Hashie::Mash.new(
    :path      => path,
    :templates => {},
  )

  instance_eval(&block)
end

Private Instance Methods

dynamo_db(region, &block) click to toggle source
# File lib/dyna/dsl.rb, line 48
def dynamo_db(region, &block)
  ddb = @result.ddbs[region]
  tables = ddb ? ddb.tables : []
  @result.ddbs[region] = DynamoDB.new(@context, tables, &block).result
end
require(file) click to toggle source
# File lib/dyna/dsl.rb, line 36
def require(file)
  tablefile = (file =~ %r|\A/|) ? file : File.expand_path(File.join(File.dirname(@path), file))

  if File.exist?(tablefile)
    instance_eval(File.read(tablefile), tablefile)
  elsif File.exist?(tablefile + '.rb')
    instance_eval(File.read(tablefile + '.rb'), tablefile + '.rb')
  else
    Kernel.require(file)
  end
end
template(name, &block) click to toggle source
# File lib/dyna/dsl.rb, line 32
def template(name, &block)
  @context.templates[name.to_s] = block
end