Sha256: 1573bb811d6aa320d7897ce39fa14533e760663cd6c56bf821326505d662c6df
Contents?: true
Size: 990 Bytes
Versions: 28
Compression:
Stored size: 990 Bytes
Contents
class Miam::DSL::Context::User include Miam::TemplateHelper def initialize(context, name, &block) @user_name = name @context = context.merge(:user_name => name) @result = {:groups => [], :policies => {}, :attached_managed_policies => []} instance_eval(&block) end attr_reader :result private def login_profile(value) @result[:login_profile] = value end def groups(*grps) @result[:groups].concat(grps.map(&:to_s)) end def policy(name) name = name.to_s if @result[:policies][name] raise "User `#{@user_name}` > Policy `#{name}`: already defined" end policy_document = yield unless policy_document.kind_of?(Hash) raise "User `#{@user_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