Module: Consumer::Mapping
- Defined in:
- lib/consumer/mapping.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#association_from_xml(xml, association, klass = nil) ⇒ Object
Same as doing:.
Class Method Details
.included(base) ⇒ Object
2 3 4 |
# File 'lib/consumer/mapping.rb', line 2 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#association_from_xml(xml, association, klass = nil) ⇒ Object
Same as doing:
self.association(s) = Association.from_xml(xml)
Behaviors
-
sets the association to a call to Klass.from_xml
Parameters
xml
-
String of xml
association
-
The association name (i.e. self.something)
klass
-
The association class (i.e. Something.from_xml). Defaults to singular, capitalized
association
.
Returns
Nothing in particular
21 22 23 24 25 26 27 28 |
# File 'lib/consumer/mapping.rb', line 21 def association_from_xml(xml, association, klass = nil) klass ||= association.to_s.capitalize.singularize.camelcase.constantize association_instance = klass.from_xml(xml) return if association_instance.nil? self.send(association.to_s + "=", association_instance) end |