Class: ZendeskRails::Comment

Inherits:
Resource show all
Defined in:
app/models/zendesk_rails/comment.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#attributes

Instance Method Summary collapse

Methods inherited from Resource

has_fields, #method_missing, #persisted?, resource_not_found!, #respond_to_missing?

Constructor Details

#initialize(ticket, attributes = {}) ⇒ Comment

Returns a new instance of Comment.



8
9
10
11
# File 'app/models/zendesk_rails/comment.rb', line 8

def initialize(ticket, attributes = {})
  @ticket = ticket
  super(attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ZendeskRails::Resource

Instance Attribute Details

#ticketObject (readonly)

Returns the value of attribute ticket.



3
4
5
# File 'app/models/zendesk_rails/comment.rb', line 3

def ticket
  @ticket
end

Instance Method Details

#saveObject



13
14
15
16
17
# File 'app/models/zendesk_rails/comment.rb', line 13

def save
  return false unless valid?
  ticket.comment = { body: comment, author_id: requester_id }
  ticket.save
end