Sha256: 4e56c48473d64f73bf990e8a98988db857167d4400ab961d5f38f68dcba9ba74

Contents?: true

Size: 596 Bytes

Versions: 2

Compression:

Stored size: 596 Bytes

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 = {})
        @clazz = Humidifier[opts[:to]]
        raise Error, "Invalid resource: #{opts[:to].inspect}" if @clazz.nil?

        @mapper = opts.fetch(:using, BaseMapper).new
      end

      def resource_for(name, attributes)
        mapper.resource_for(clazz, name, attributes)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
humidifier-reservoir-0.1.0 lib/humidifier/reservoir/mapping.rb
humidifier-reservoir-0.0.1 lib/humidifier/reservoir/mapping.rb