Sha256: 9f6a2aedb051dd811cca3c579aeaa162a8594b026ee0f925bf52ee755cc10214

Contents?: true

Size: 839 Bytes

Versions: 28

Compression:

Stored size: 839 Bytes

Contents

class Miam::DSL::Context::Group
  include Miam::TemplateHelper

  def initialize(context, name, &block)
    @group_name = name
    @context = context.merge(:group_name => name)
    @result = {:policies => {}, :attached_managed_policies => []}
    instance_eval(&block)
  end

  attr_reader :result

  private

  def policy(name)
    name = name.to_s

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

    policy_document = yield

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

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

  def attached_managed_policies(*policies)
    @result[:attached_managed_policies].concat(policies.map(&:to_s))
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
miam-0.2.3 lib/miam/dsl/context/group.rb
miam-0.2.3.beta3 lib/miam/dsl/context/group.rb
miam-0.2.3.beta2 lib/miam/dsl/context/group.rb
miam-0.2.3.beta lib/miam/dsl/context/group.rb
miam-0.2.2 lib/miam/dsl/context/group.rb
miam-0.2.2.beta4 lib/miam/dsl/context/group.rb
miam-0.2.2.beta3 lib/miam/dsl/context/group.rb
miam-0.2.2.beta2 lib/miam/dsl/context/group.rb