Sha256: fb13d47f3774f11a508baa8d447d49c45702c32d8c4d5d689171392581f9883b

Contents?: true

Size: 867 Bytes

Versions: 7

Compression:

Stored size: 867 Bytes

Contents

class Lbrt::Alert::DSL::Context
  include Lbrt::Utils::ContextHelper
  include Lbrt::Utils::TemplateHelper

  def self.eval(client, dsl, path, options = {})
    self.new(client, path, options) {
      eval(dsl, binding, path)
    }
  end

  attr_reader :result
  attr_reader :context

  def initialize(client, path, options = {}, &block)
    @path = path
    @options = options
    @result = {}
    @services = Lbrt::Service::Exporter.export(client, options)

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

    instance_eval(&block)
  end

  private

  def alert(name, &block)
    name = name.to_s

    if @result[name]
      raise "Alert `#{name}` is already defined"
    end

    alrt = Lbrt::Alert::DSL::Context::Alert.new(@context, name, @services, &block).result
    @result[name] = alrt
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lbrt-0.2.1 lib/lbrt/alert/dsl/context.rb
lbrt-0.2.0 lib/lbrt/alert/dsl/context.rb
lbrt-0.1.9 lib/lbrt/alert/dsl/context.rb
lbrt-0.1.8 lib/lbrt/alert/dsl/context.rb
lbrt-0.1.7 lib/lbrt/alert/dsl/context.rb
lbrt-0.1.6 lib/lbrt/alert/dsl/context.rb
lbrt-0.1.5 lib/lbrt/alert/dsl/context.rb