Class: TicketAbstractorClient::Base::Comment
- Inherits:
-
Object
- Object
- TicketAbstractorClient::Base::Comment
- Defined in:
- lib/ticket_abstractor_client/base/comment.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#communications_stack ⇒ Object
readonly
Returns the value of attribute communications_stack.
-
#data_hash ⇒ Object
readonly
Returns the value of attribute data_hash.
-
#external_created_at ⇒ Object
readonly
Returns the value of attribute external_created_at.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Comment
constructor
A new instance of Comment.
- #set_data_hash! ⇒ Object
- #sync! ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(opts) ⇒ Comment
Returns a new instance of Comment.
10 11 12 13 14 15 16 17 18 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 10 def initialize(opts) opts = opts.with_indifferent_access @author = opts[:author] @body = opts.fetch(:body, nil) || raise(Errors::CommentArgumentError, 'Body is not given') @external_created_at = opts[:external_created_at] @data_hash = opts[:data_hash] @communications_stack = opts[:communications_stack] || [] set_data_hash! if @data_hash.blank? end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 4 def @author end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 4 def body @body end |
#communications_stack ⇒ Object (readonly)
Returns the value of attribute communications_stack.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 4 def communications_stack @communications_stack end |
#data_hash ⇒ Object (readonly)
Returns the value of attribute data_hash.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 4 def data_hash @data_hash end |
#external_created_at ⇒ Object (readonly)
Returns the value of attribute external_created_at.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 4 def external_created_at @external_created_at end |
Class Method Details
.fetch(*opts) ⇒ Object
6 7 8 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 6 def self.fetch(*opts) method_not_implemented __method__ end |
Instance Method Details
#set_data_hash! ⇒ Object
20 21 22 23 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 20 def set_data_hash! content = "#{@external_created_at}:#{@author}:#{@body}" @data_hash = Digest::SHA512.hexdigest(content) end |
#sync! ⇒ Object
25 26 27 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 25 def sync! self.class.method_not_implemented __method__ end |
#to_hash ⇒ Object
29 30 31 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 29 def to_hash { author: @author, body: @body, external_created_at: @external_created_at, data_hash: @data_hash } end |
#to_json ⇒ Object
33 34 35 |
# File 'lib/ticket_abstractor_client/base/comment.rb', line 33 def to_json self.to_hash.to_json end |