Class: Humidifier::Reservoir::Mapping

Inherits:
Object
  • Object
show all
Defined in:
lib/humidifier/reservoir/mapping.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, &block) ⇒ Mapping

Returns a new instance of Mapping.

Raises:



9
10
11
12
13
14
15
16
17
18
# File 'lib/humidifier/reservoir/mapping.rb', line 9

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

Instance Attribute Details

#clazzObject (readonly)

Returns the value of attribute clazz.



7
8
9
# File 'lib/humidifier/reservoir/mapping.rb', line 7

def clazz
  @clazz
end

#mapperObject (readonly)

Returns the value of attribute mapper.



7
8
9
# File 'lib/humidifier/reservoir/mapping.rb', line 7

def mapper
  @mapper
end

Instance Method Details

#resource_for(name, attributes) ⇒ Object



20
21
22
# File 'lib/humidifier/reservoir/mapping.rb', line 20

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