Sha256: 87c21b979d02413468064da8f04d1909ce8af1307ac223883738daedaefcd1bb

Contents?: true

Size: 575 Bytes

Versions: 2

Compression:

Stored size: 575 Bytes

Contents

class Miam::DSL::Context::Group
  def initialize(name, &block)
    @name = name
    @result = {:policies => {}}
    instance_eval(&block)
  end

  attr_reader :result

  private

  def policy(name)
    name = name.to_s

    if @result[:policies][name]
      raise "Group `#{name}` > Policy `#{name}`: already defined"
    end

    policy_document = yield

    unless policy_document.kind_of?(Hash)
      raise "Group `#{name}` > Policy `#{name}`: wrong argument type #{policy_document.class} (expected Hash)"
    end

    @result[:policies][name] = policy_document
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miam-0.1.0 lib/miam/dsl/context/group.rb
miam-0.1.0.beta lib/miam/dsl/context/group.rb