has (DataMapper::Model::Relationship)

    # File lib/dm-core/model/relationship.rb, line 101
          def has(cardinality, name, *args)
            assert_kind_of 'cardinality', cardinality, Integer, Range, n.class
            assert_kind_of 'name',        name,        Symbol

            model   = extract_model(args)
            options = extract_options(args)

            min, max = extract_min_max(cardinality)
            options.update(:min => min, :max => max)

            assert_valid_options(options)

            if options.key?(:model) && model
              raise ArgumentError, 'should not specify options[:model] if passing the model in the third argument'
            end

            model ||= options.delete(:model)

            repository_name = repository.name

            # TODO: change to :target_respository_name and :source_repository_name
            options[:child_repository_name]  = options.delete(:repository)
            options[:parent_repository_name] = repository_name

            klass = if options[:max] > 1
              options.key?(:through) ? Associations::ManyToMany::Relationship : Associations::OneToMany::Relationship
            else
              Associations::OneToOne::Relationship
            end

            relationship = relationships(repository_name)[name] = klass.new(name, model, self, options)

            descendants.each do |descendant|
              descendant.relationships(repository_name)[name] ||= relationship
            end

            relationship
          end