def merge_attributes(attrs={})
    # copy attributes from the parent module fields array
    @attributes = self.class.attributes_from_module
    # populate the attributes with values from the attrs provided to init.
    @attributes.keys.each do |name|
      write_attribute name, attrs[name] if attrs[name]
    end
    # If this is an existing record, blank out the modified_attributes hash
    @modified_attributes = {} unless new?
  end
def merge_attributes(attrs={})
    # copy attributes from the parent module fields array
    @attributes = self.class.attributes_from_module
    # populate the attributes with values from the attrs provided to init.
    @attributes.keys.each do |name|
      write_attribute name, attrs[name] if attrs[name]
    end
    # If this is an existing record, blank out the modified_attributes hash
    @modified_attributes = {} unless new?
  end
Merges attributes provided as an argument to initialize
 with attributes from the module.fields array.  Skips any
 fields that aren't in the module.fields array

 BUG: SugarCRM likes to return fields you don't ask for and
 aren't fields on a module (i.e. modified_user_name).  This
 royally screws up our typecasting code, so we handle it here.