Class: Humidifier::Config::Mapping
- Inherits:
-
Object
- Object
- Humidifier::Config::Mapping
- Defined in:
- lib/humidifier/config/mapping.rb
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.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/humidifier/config/mapping.rb', line 8 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.
6 7 8 |
# File 'lib/humidifier/config/mapping.rb', line 6 def clazz @clazz end |
#mapper ⇒ Object (readonly)
Returns the value of attribute mapper.
6 7 8 |
# File 'lib/humidifier/config/mapping.rb', line 6 def mapper @mapper end |
Instance Method Details
#resource_for(name, attributes) ⇒ Object
19 20 21 |
# File 'lib/humidifier/config/mapping.rb', line 19 def resource_for(name, attributes) mapper.resource_for(clazz, name, attributes) end |