Sha256: ee4834894eb10f4a4e7ac5f64602d0dae359243e83179cbdf0925378b3c273be
Contents?: true
Size: 1.31 KB
Versions: 9
Compression:
Stored size: 1.31 KB
Contents
class Miam::DSL::Context::Role def initialize(name, &block) @role_name = name @result = {:instance_profiles => [], :policies => {}} instance_eval(&block) end def result unless @result[:assume_role_policy_document] raise "Role `#{@role_name}`: AssumeRolePolicyDocument is not defined" end @result end private def instance_profiles(*profiles) @result[:instance_profiles].concat(profiles.map {|i| i.to_s }) end def assume_role_policy_document if @result[:assume_role_policy_document] raise "Role `#{@role_name}` > AssumeRolePolicyDocument: already defined" end assume_role_policy_document = yield unless assume_role_policy_document.kind_of?(Hash) raise "Role `#{@role_name}` > AssumeRolePolicyDocument: wrong argument type #{policy_document.class} (expected Hash)" end @result[:assume_role_policy_document] = assume_role_policy_document end def policy(name) name = name.to_s if @result[:policies][name] raise "Role `#{@role_name}` > Policy `#{name}`: already defined" end policy_document = yield unless policy_document.kind_of?(Hash) raise "Role `#{@role_name}` > Policy `#{name}`: wrong argument type #{policy_document.class} (expected Hash)" end @result[:policies][name] = policy_document end end
Version data entries
9 entries across 9 versions & 1 rubygems