Class: Preneeds::PreneedAttachmentHash

Inherits:
Base
  • Object
show all
Defined in:
app/models/preneeds/preneed_attachment_hash.rb

Overview

Models a BurialForm form attachment. This is the data about the actual attachment, Attachment.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_json

Methods included from Vets::Model

#attributes, #initialize, #nested_attributes

Methods included from Vets::Attributes

included

Instance Attribute Details

#attachment_idString

Returns attachment id.

Returns:

  • (String)

    attachment id



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/preneeds/preneed_attachment_hash.rb', line 14

class PreneedAttachmentHash < Preneeds::Base
  attribute :confirmation_code, String
  attribute :attachment_id, String
  attribute :name, String

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    %i[confirmation_code attachment_id name]
  end

  # @return [CarrierWave::Storage::AWSFile, CarrierWave::SanitizedFile] the previously uploaded file
  #
  def get_file
    ::Preneeds::PreneedAttachment.find_by(guid: confirmation_code).get_file
  end

  # @return [Preneeds::Attachment] the {Preneeds::Attachment} documented by this objects attributes
  #
  def to_attachment
    Preneeds::Attachment.new(
      attachment_type: AttachmentType.new(
        attachment_type_id: attachment_id
      ),
      file: get_file,
      name:
    )
  end
end

#confirmation_codeString

Returns guid of uploaded attachment.

Returns:

  • (String)

    guid of uploaded attachment



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/preneeds/preneed_attachment_hash.rb', line 14

class PreneedAttachmentHash < Preneeds::Base
  attribute :confirmation_code, String
  attribute :attachment_id, String
  attribute :name, String

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    %i[confirmation_code attachment_id name]
  end

  # @return [CarrierWave::Storage::AWSFile, CarrierWave::SanitizedFile] the previously uploaded file
  #
  def get_file
    ::Preneeds::PreneedAttachment.find_by(guid: confirmation_code).get_file
  end

  # @return [Preneeds::Attachment] the {Preneeds::Attachment} documented by this objects attributes
  #
  def to_attachment
    Preneeds::Attachment.new(
      attachment_type: AttachmentType.new(
        attachment_type_id: attachment_id
      ),
      file: get_file,
      name:
    )
  end
end

#nameString

Returns attachment file name.

Returns:

  • (String)

    attachment file name



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/preneeds/preneed_attachment_hash.rb', line 14

class PreneedAttachmentHash < Preneeds::Base
  attribute :confirmation_code, String
  attribute :attachment_id, String
  attribute :name, String

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    %i[confirmation_code attachment_id name]
  end

  # @return [CarrierWave::Storage::AWSFile, CarrierWave::SanitizedFile] the previously uploaded file
  #
  def get_file
    ::Preneeds::PreneedAttachment.find_by(guid: confirmation_code).get_file
  end

  # @return [Preneeds::Attachment] the {Preneeds::Attachment} documented by this objects attributes
  #
  def to_attachment
    Preneeds::Attachment.new(
      attachment_type: AttachmentType.new(
        attachment_type_id: attachment_id
      ),
      file: get_file,
      name:
    )
  end
end

Class Method Details

.permitted_paramsArray

List of permitted params for use with Strong Parameters

Returns:

  • (Array)

    array of class attributes as symbols



21
22
23
# File 'app/models/preneeds/preneed_attachment_hash.rb', line 21

def self.permitted_params
  %i[confirmation_code attachment_id name]
end

Instance Method Details

#get_fileCarrierWave::Storage::AWSFile, CarrierWave::SanitizedFile

Returns the previously uploaded file.

Returns:

  • (CarrierWave::Storage::AWSFile, CarrierWave::SanitizedFile)

    the previously uploaded file



27
28
29
# File 'app/models/preneeds/preneed_attachment_hash.rb', line 27

def get_file
  ::Preneeds::PreneedAttachment.find_by(guid: confirmation_code).get_file
end

#to_attachmentPreneeds::Attachment

Returns the Attachment documented by this objects attributes.

Returns:



33
34
35
36
37
38
39
40
41
# File 'app/models/preneeds/preneed_attachment_hash.rb', line 33

def to_attachment
  Preneeds::Attachment.new(
    attachment_type: AttachmentType.new(
      attachment_type_id: attachment_id
    ),
    file: get_file,
    name:
  )
end