writer_method(name, class_name, mapping, allow_nil) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/aggregations.rb, line 167
        def writer_method(name, class_name, mapping, allow_nil)
          mapping = (Array === mapping.first ? mapping : [ mapping ])

          if allow_nil
            module_eval "def \#{name}=(part)\nif part.nil?\n\#{mapping.collect { |pair| \"@attributes[\\\"\#{pair.first}\\\"] = nil\" }.join(\"\\n\")}\nelse\n@\#{name} = part.freeze\n\#{mapping.collect { |pair| \"@attributes[\\\"\#{pair.first}\\\"] = part.\#{pair.last}\" }.join(\"\\n\")}\nend\nend\n"
          else
            module_eval "def \#{name}=(part)\n@\#{name} = part.freeze\n\#{mapping.collect{ |pair| \"@attributes[\\\"\#{pair.first}\\\"] = part.\#{pair.last}\" }.join(\"\\n\")}\nend\n"
          end
        end
Register or log in to add new notes.