Class: TicketAbstractorClient::Base::Attachment
- Inherits:
-
Object
- Object
- TicketAbstractorClient::Base::Attachment
- Defined in:
- lib/ticket_abstractor_client/base/attachment.rb
Direct Known Subclasses
Constant Summary collapse
- SANITIZE_REGEXP =
Carrierwave uses the same regexp
/[^[:word:]\.\-\+]/
Instance Attribute Summary collapse
-
#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.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Attachment
constructor
A new instance of Attachment.
- #set_data_hash! ⇒ Object
- #sync! ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(opts) ⇒ Attachment
Returns a new instance of Attachment.
37 38 39 40 41 42 43 |
# File 'lib/ticket_abstractor_client/base/attachment.rb', line 37 def initialize(opts) @file_path = opts[:file_path] @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
#communications_stack ⇒ Object (readonly)
Returns the value of attribute communications_stack.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/attachment.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/attachment.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/attachment.rb', line 4 def external_created_at @external_created_at end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/attachment.rb', line 4 def file_path @file_path end |
Class Method Details
.fetch ⇒ Object
10 11 12 |
# File 'lib/ticket_abstractor_client/base/attachment.rb', line 10 def fetch method_not_implemented __method__ end |
Instance Method Details
#set_data_hash! ⇒ Object
49 50 51 52 53 54 |
# File 'lib/ticket_abstractor_client/base/attachment.rb', line 49 def set_data_hash! return if self.file_path.blank? file = File.new(self.file_path, 'rb') @data_hash = Digest::SHA512.hexdigest(file.read) file.close end |
#sync! ⇒ Object
45 46 47 |
# File 'lib/ticket_abstractor_client/base/attachment.rb', line 45 def sync! self.class.method_not_implemented __method__ end |
#to_hash ⇒ Object
56 57 58 |
# File 'lib/ticket_abstractor_client/base/attachment.rb', line 56 def to_hash { file_path: @file_path, external_created_at: @external_created_at, data_hash: @data_hash } end |
#to_json ⇒ Object
60 61 62 |
# File 'lib/ticket_abstractor_client/base/attachment.rb', line 60 def to_json self.to_hash.to_json end |