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.5.beta1 lib/miam/dsl/context/group.rb
miam-0.2.4 lib/miam/dsl/context/group.rb
miam-0.2.4.beta18 lib/miam/dsl/context/group.rb
miam-0.2.4.beta17 lib/miam/dsl/context/group.rb
miam-0.2.4.beta16 lib/miam/dsl/context/group.rb
miam-0.2.4.beta15 lib/miam/dsl/context/group.rb
miam-0.2.4.beta14 lib/miam/dsl/context/group.rb
miam-0.2.4.beta13 lib/miam/dsl/context/group.rb
miam-0.2.4.beta12 lib/miam/dsl/context/group.rb
miam-0.2.4.beta11 lib/miam/dsl/context/group.rb
miam-0.2.4.beta10 lib/miam/dsl/context/group.rb
miam-0.2.4.beta9 lib/miam/dsl/context/group.rb
miam-0.2.4.beta8 lib/miam/dsl/context/group.rb
miam-0.2.4.beta7 lib/miam/dsl/context/group.rb
miam-0.2.4.beta6 lib/miam/dsl/context/group.rb
miam-0.2.4.beta5 lib/miam/dsl/context/group.rb
miam-0.2.4.beta4 lib/miam/dsl/context/group.rb
miam-0.2.4.beta3 lib/miam/dsl/context/group.rb
miam-0.2.4.beta2 lib/miam/dsl/context/group.rb
miam-0.2.4.beta lib/miam/dsl/context/group.rb