Sha256: f2273dbbee3697c6e6d079d1b04e9e8746cd88336539b76dd36d6c1318137b8d

Contents?: true

Size: 1.63 KB

Versions: 8

Compression:

Stored size: 1.63 KB

Contents

class YouTrack::Client::Project < YouTrack::Client::Model
  identity :id, aliases: ["shortName"]

  attribute :versions,     type: :array, default: []
  attribute :name
  attribute :description
  attribute :is_importing, type: :boolean, aliases: ["isImporting"]
  attribute :assignees

  attr_accessor :starting_number, :lead, :prefix

  def issues
    service.issues.all(self.identity)
  end

  def custom_fields
    service.get_project_custom_fields(self.id).body
  end

  def save
    if new_record?
      requires :name, :prefix

      starting_number = self.starting_number || 1
      lead            = self.lead            || service.current_user

      lead_id = (lead.is_a?(YouTrack::Client::User) ? lead.identity : lead)

      service.create_project(
        "projectId"        => self.prefix,
        "projectName"      => self.name,
        "startingNumber"   => starting_number,
        "projectLeadLogin" => lead_id,
        "description"      => self.description,
      )

      merge_attributes(
        :identity => self.prefix,
      )
    else
      raise NotImplementedError
    end
  end

  def add_version(version)
    require_admin!

    unless versions.include?(version)
      service.add_project_fix_version('project' => self.id, 'version' => version)
      self.versions << version
    end

    self.versions
  end

  def reload
    merge_attributes(collection.reload.get(self.identity).attributes)
  end

  def remove_version(version)
    require_admin!

    if versions.include?(version)
      service.remove_project_fix_version('project' => self.id, 'version' => version)
      self.versions.delete(version)
    end

    self.versions
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
you_track-0.4.8 lib/you_track/client/models/project.rb
you_track-0.4.7 lib/you_track/client/models/project.rb
you_track-0.4.6 lib/you_track/client/models/project.rb
you_track-0.4.5 lib/you_track/client/models/project.rb
you_track-0.4.4 lib/you_track/client/models/project.rb
you_track-0.4.2 lib/you_track/client/models/project.rb
you_track-0.4.1 lib/you_track/client/models/project.rb
you_track-0.4.0 lib/you_track/client/models/project.rb