Sha256: 716275d477e35b93794b2d2a1296ab9e913149acfa054d7d3bf6b389a6af5be4
Contents?: true
Size: 753 Bytes
Versions: 9
Compression:
Stored size: 753 Bytes
Contents
class Miam::DSL::Context::User def initialize(name, &block) @user_name = name @result = {:groups => [], :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 {|i| i.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 end
Version data entries
9 entries across 9 versions & 1 rubygems