Class: TicketMaster::Provider::Github::Comment
- Inherits:
-
Base::Comment
- Object
- Base::Comment
- TicketMaster::Provider::Github::Comment
- Defined in:
- lib/provider/comment.rb
Overview
The comment class for ticketmaster-github
Do any mapping between Ticketmaster and your system’s comment model here versions of the ticket.
Instance Attribute Summary collapse
-
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
Class Method Summary collapse
- .clean_body!(comment) ⇒ Object
- .create(project_id, ticket_id, comment) ⇒ Object
- .find_all(project_id, ticket_id) ⇒ Object
-
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
declare needed overloaded methods here.
- .flat_body(comment_hashie) ⇒ Object
Instance Method Summary collapse
- #author ⇒ Object
- #created_at ⇒ Object
-
#initialize(*object) ⇒ Comment
constructor
A new instance of Comment.
- #save ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Comment
Returns a new instance of Comment.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/provider/comment.rb', line 11 def initialize(*object) if object.first object = object.first unless object.is_a? Hash hash = {:id => object.id, :body => object.body, :created_at => object.created_at, :author => object.user.login} else hash = object end super hash end end |
Instance Attribute Details
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
9 10 11 |
# File 'lib/provider/comment.rb', line 9 def @prefix_options end |
Class Method Details
.clean_body!(comment) ⇒ Object
74 75 76 |
# File 'lib/provider/comment.rb', line 74 def self.clean_body!(comment) comment.body = comment.body.sub(/\A---\s\sbody:\s/, '').gsub(/\s\z/, '') end |
.create(project_id, ticket_id, comment) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/provider/comment.rb', line 60 def self.create(project_id, ticket_id, comment) github_comment = TicketMaster::Provider::Github.api.add_comment(project_id, ticket_id, comment) github_comment.merge!(:project_id => project_id, :ticket_id => ticket_id) flat_body github_comment self.new github_comment end |
.find_all(project_id, ticket_id) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/provider/comment.rb', line 52 def self.find_all(project_id, ticket_id) TicketMaster::Provider::Github.api.issue_comments(project_id, ticket_id).collect do |comment| comment.merge!(:project_id => project_id, :ticket_id => ticket_id) clean_body! comment self.new comment end end |
.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object
declare needed overloaded methods here
48 49 50 |
# File 'lib/provider/comment.rb', line 48 def self.find_by_attributes(project_id, ticket_id, attributes = {}) search_by_attribute(self.find_all(project_id, ticket_id), attributes) end |
.flat_body(comment_hashie) ⇒ Object
68 69 70 71 |
# File 'lib/provider/comment.rb', line 68 def self.flat_body(comment_hashie) comment_hashie.body = comment_hashie.body.body comment_hashie end |
Instance Method Details
#author ⇒ Object
26 27 28 |
# File 'lib/provider/comment.rb', line 26 def self.user.login end |
#created_at ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/provider/comment.rb', line 30 def created_at @created_at ||= begin Time.parse(self[:created_at]) rescue self[:created_at] end end |
#save ⇒ Object
78 79 80 |
# File 'lib/provider/comment.rb', line 78 def save update_comment(project_id, id, body) end |
#updated_at ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/provider/comment.rb', line 38 def updated_at @updated_at ||= begin Time.parse(self[:updated_at]) rescue self[:updated_at] end end |