lib/dox/dsl/resource_group.rb in dox-0.0.3 vs lib/dox/dsl/resource_group.rb in dox-1.0.0.alpha

- old
+ new

@@ -4,20 +4,22 @@ include AttrProxy attr_writer :name attr_writer :desc - def initialize(opts = {}) - self.name = opts.fetch(:name, nil) - self.desc = opts.fetch(:desc, nil) + def initialize(name, &block) + self.name = name + instance_eval(&block) if block_given? + + raise(Dox::Errors::InvalidResourceGroupError, 'Resource group name is required!') if @name.blank? end def config - {}.tap do |config| - config[:resource_group_name] = @name if @name - config[:resource_group_desc] = @desc if @desc - config[:apidoc] = true - end + { + resource_group_name: @name.presence, + resource_group_desc: @desc.presence, + apidoc: true + } end end end end