Class: Humidifier::Reservoir::Mapping
- Inherits:
-
Object
- Object
- Humidifier::Reservoir::Mapping
- 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
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
-
#mapper ⇒ Object
readonly
Returns the value of attribute mapper.
Instance Method Summary collapse
-
#initialize(opts = {}, &block) ⇒ Mapping
constructor
A new instance of Mapping.
- #resource_for(name, attributes) ⇒ Object
Constructor Details
#initialize(opts = {}, &block) ⇒ Mapping
Returns a new instance of Mapping.
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
#clazz ⇒ Object (readonly)
Returns the value of attribute clazz.
7 8 9 |
# File 'lib/humidifier/reservoir/mapping.rb', line 7 def clazz @clazz end |
#mapper ⇒ Object (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 |