def build_associate(model, options = {})
      model_name                = model.to_s.underscore
      model_klass               = (options[:class_name] || model).to_s.classify.constantize
      dependent_associate_names = options[:depends_on].map(&:to_s)
      attribute_names           = extract_attribute_names(model_klass, options)

      ensure_name_uniqueness(associates.map(&:name), model_name)
      ensure_attribute_uniqueness(associates.map(&:attribute_names), attribute_names) if options[:delegate]
      ensure_dependent_names_existence(associates.map(&:name), dependent_associate_names)

      Item.new(model_name, model_klass, attribute_names, dependent_associate_names, options)
    end
def build_associate(model, options = {})
      model_name                = model.to_s.underscore
      model_klass               = (options[:class_name] || model).to_s.classify.constantize
      dependent_associate_names = options[:depends_on].map(&:to_s)
      attribute_names           = extract_attribute_names(model_klass, options)

      ensure_name_uniqueness(associates.map(&:name), model_name)
      ensure_attribute_uniqueness(associates.map(&:attribute_names), attribute_names) if options[:delegate]
      ensure_dependent_names_existence(associates.map(&:name), dependent_associate_names)

      Item.new(model_name, model_klass, attribute_names, dependent_associate_names, options)
    end
Builds an associate

 @param model [Symbol, Class]
 @param options [Hash]
 @return [Item]