Class: TicketMaster::Provider::Kanbanpad::Project

Inherits:
Base::Project
  • Object
show all
Defined in:
lib/provider/project.rb

Overview

Project class for ticketmaster-kanbanpad

Constant Summary collapse

API =

declare needed overloaded methods here

KanbanpadAPI::Project
COMMENT_API =
KanbanpadAPI::ProjectComment

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Project

Returns a new instance of Project.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/provider/project.rb', line 11

def initialize(*object)
  if object.first
    object = object.first
    @system_data = {:client => object}
    unless object.is_a? Hash
      hash = {:id => object.slug,
              :name => object.name, 
              :slug => object.slug,
              :created_at => object.created_at,
              :updated_at => object.updated_at}
    else
      hash = object
    end
    super hash
  end
end

Instance Method Details

#comment!(attributes) ⇒ Object



59
60
61
62
# File 'lib/provider/project.rb', line 59

def comment!(attributes)
  comment = create_comment attributes
  Comment.new(comment.attributes.merge :project_id => id) if comment.save
end

#commentsObject



64
65
66
# File 'lib/provider/project.rb', line 64

def comments
  find_comments.map { |c| Comment.new c.attributes }
end

#copy(project) ⇒ Object

copy from this.copy(that) copies that into this



29
30
31
32
33
34
35
36
37
# File 'lib/provider/project.rb', line 29

def copy(project)
  project.tickets.each do |ticket|
    copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
    ticket.comments.each do |comment|
      copy_ticket.comment!(:body => comment.body)
      sleep 1
    end
  end
end

#created_atObject



43
44
45
46
47
48
49
# File 'lib/provider/project.rb', line 43

def created_at
  begin
    Time.parse(self[:created_at])
  rescue
    self[:created_at]
  end
end

#idObject



39
40
41
# File 'lib/provider/project.rb', line 39

def id
  self[:slug]
end

#updated_atObject



51
52
53
54
55
56
57
# File 'lib/provider/project.rb', line 51

def updated_at
  begin
    Time.parse(self[:updated_at])
  rescue
    self[:updated_at]
  end
end