Sha256: 76d8dfd328fa45cf468e79bef184b854a5f6a84e725bc28b37ea23d84ae0f5b5
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
module Humidifier module Reservoir # Contains the configuration for a mapping between a YAML file name and an # AWS resource. May optionally contain a Mapper (uses the BaseMapper) by # default. class Mapping attr_reader :clazz, :mapper def initialize(opts = {}, &block) @clazz = Humidifier[normalized(opts[:to])] raise Error, "Invalid resource: #{opts[:to].inspect}" if @clazz.nil? if opts[:using] && block_given? raise Error, 'Cannot specify :using and provide an anonymous mapper' end @mapper = mapper_from(opts, &block) end def resource_for(name, attributes) mapper.resource_for(clazz, name, attributes) end private def mapper_from(opts, &block) if opts[:using] opts[:using].new elsif block_given? Class.new(BaseMapper, &block).new else BaseMapper.new end end def normalized(to) to.start_with?('AWS') ? to : "AWS::#{to}" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems