Sha256: a1e599547bc81782552700263ac7e15b136e7916fd8dddb1e63d1ed8c652b08f

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

class Project
  include Mongoid::Document
  include Rally::ParsingHelpers
  extend Rally::ParsingHelperClassMethods

  class << self
    def rally_uri
      "/project.js"
    end
  end

  field :name
  field :rally_uri
  field :created_on
  field :description
  field :notes
  field :state

  referenced_in :parent, :class_name => "Project"
  references_many :children, :class_name => "Project"
  references_many :iterations  
  references_many :stories
  embeds_one :revision_parser
  
  def refresh hash_values=nil
    @rally_hash = hash_values if hash_values
    from_rally :name
    from_rally :description
    from_rally :state
    from_rally :notes

    self.save

  end
  
  #must be called after refresh, or with has_values passed in
  def associate hash_values=nil
    @rally_hash = hash_values || RallyAPI.get(self)
    #TODO: associate with user when users are supported
    if @rally_hash["Parent"]
      parent = Project.find_or_create_by(:rally_uri => @rally_hash["Parent"]["_ref"])
      parent.children << self
      parent.save
      self.parent = parent
    end
    self.save
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rallytastic-1.4.8 lib/project.rb
rallytastic-1.4.7 lib/project.rb
rallytastic-1.4.6 lib/project.rb
rallytastic-1.4.5 lib/project.rb
rallytastic-1.4.4 lib/project.rb
rallytastic-1.4.0 lib/project.rb
rallytastic-1.3.0 lib/project.rb
rallytastic-1.2.8 lib/project.rb