Sha256: 1ba19b0a86130416a68e4dbc9ac92b5c516605a3604572a9eb33cbdcd3bf1f77

Contents?: true

Size: 846 Bytes

Versions: 7

Compression:

Stored size: 846 Bytes

Contents

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

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

  attr_reader :result
  attr_reader :context

  def initialize(path, options = {}, &block)
    @path = path
    @options = options
    @result = {}

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

    instance_eval(&block)
  end

  private

  def service(type, title, &block)
    type = type.to_s
    title = title.to_s
    key = [type, title]

    if @result[key]
      raise "Service `#{type}/#{title}` is already defined"
    end

    srvc = Lbrt::Service::DSL::Context::Service.new(@context, type, title, &block).result
    @result[key] = srvc
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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