Class: Preneeds::Attachment
- Defined in:
- app/models/preneeds/attachment.rb
Overview
Models a BurialForm form attachment
Constant Summary collapse
- VETS_GOV =
string to populate #sending_source
'vets.gov'
Instance Attribute Summary collapse
-
#attachment_type ⇒ Preneeds::AttachmentType
AttachmentType object.
-
#data_handler ⇒ String
Auto-generated attachment id.
- #file ⇒ CarrierWave::Storage::AWSFile, CarrierWave::SanitizedFile
-
#name ⇒ String
Attachment name.
-
#sending_source ⇒ String
Sending source; currently hard coded.
Instance Method Summary collapse
-
#as_eoas ⇒ Hash
Converts object attributes to a hash to be used when constructing a SOAP request body.
-
#initialize(*args) ⇒ Attachment
constructor
Creates a new instance of Attachment.
Methods inherited from Base
Methods included from Vets::Model
#attributes, #nested_attributes
Methods included from Vets::Attributes
Constructor Details
#initialize(*args) ⇒ Attachment
Creates a new instance of Preneeds::Attachment
33 34 35 36 |
# File 'app/models/preneeds/attachment.rb', line 33 def initialize(*args) super @data_handler = SecureRandom.hex end |
Instance Attribute Details
#attachment_type ⇒ Preneeds::AttachmentType
Returns Preneeds::AttachmentType object.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/preneeds/attachment.rb', line 17 class Attachment < Preneeds::Base # string to populate #sending_source # VETS_GOV = 'vets.gov' attribute :attachment_type, Preneeds::AttachmentType attribute :sending_source, String, default: VETS_GOV attribute :file, (Rails.env.production? ? CarrierWave::Storage::AWSFile : CarrierWave::SanitizedFile) attribute :name, String attr_reader :data_handler # Creates a new instance of {Preneeds::Attachment} # # @param args [Hash] hash with keys that correspond to attributes # def initialize(*args) super @data_handler = SecureRandom.hex end # (see Preneeds::BurialForm#as_eoas) # def as_eoas { attachmentType: { attachmentTypeId: . }, dataHandler: { 'inc:Include': '', attributes!: { 'inc:Include': { href: "cid:#{@data_handler}", 'xmlns:inc': 'http://www.w3.org/2004/08/xop/include' } } }, description: name, sendingName: VETS_GOV, sendingSource: sending_source } end end |
#data_handler ⇒ String
Returns auto-generated attachment id.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/preneeds/attachment.rb', line 17 class Attachment < Preneeds::Base # string to populate #sending_source # VETS_GOV = 'vets.gov' attribute :attachment_type, Preneeds::AttachmentType attribute :sending_source, String, default: VETS_GOV attribute :file, (Rails.env.production? ? CarrierWave::Storage::AWSFile : CarrierWave::SanitizedFile) attribute :name, String attr_reader :data_handler # Creates a new instance of {Preneeds::Attachment} # # @param args [Hash] hash with keys that correspond to attributes # def initialize(*args) super @data_handler = SecureRandom.hex end # (see Preneeds::BurialForm#as_eoas) # def as_eoas { attachmentType: { attachmentTypeId: . }, dataHandler: { 'inc:Include': '', attributes!: { 'inc:Include': { href: "cid:#{@data_handler}", 'xmlns:inc': 'http://www.w3.org/2004/08/xop/include' } } }, description: name, sendingName: VETS_GOV, sendingSource: sending_source } end end |
#file ⇒ CarrierWave::Storage::AWSFile, CarrierWave::SanitizedFile
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/preneeds/attachment.rb', line 17 class Attachment < Preneeds::Base # string to populate #sending_source # VETS_GOV = 'vets.gov' attribute :attachment_type, Preneeds::AttachmentType attribute :sending_source, String, default: VETS_GOV attribute :file, (Rails.env.production? ? CarrierWave::Storage::AWSFile : CarrierWave::SanitizedFile) attribute :name, String attr_reader :data_handler # Creates a new instance of {Preneeds::Attachment} # # @param args [Hash] hash with keys that correspond to attributes # def initialize(*args) super @data_handler = SecureRandom.hex end # (see Preneeds::BurialForm#as_eoas) # def as_eoas { attachmentType: { attachmentTypeId: . }, dataHandler: { 'inc:Include': '', attributes!: { 'inc:Include': { href: "cid:#{@data_handler}", 'xmlns:inc': 'http://www.w3.org/2004/08/xop/include' } } }, description: name, sendingName: VETS_GOV, sendingSource: sending_source } end end |
#name ⇒ String
Returns attachment name.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/preneeds/attachment.rb', line 17 class Attachment < Preneeds::Base # string to populate #sending_source # VETS_GOV = 'vets.gov' attribute :attachment_type, Preneeds::AttachmentType attribute :sending_source, String, default: VETS_GOV attribute :file, (Rails.env.production? ? CarrierWave::Storage::AWSFile : CarrierWave::SanitizedFile) attribute :name, String attr_reader :data_handler # Creates a new instance of {Preneeds::Attachment} # # @param args [Hash] hash with keys that correspond to attributes # def initialize(*args) super @data_handler = SecureRandom.hex end # (see Preneeds::BurialForm#as_eoas) # def as_eoas { attachmentType: { attachmentTypeId: . }, dataHandler: { 'inc:Include': '', attributes!: { 'inc:Include': { href: "cid:#{@data_handler}", 'xmlns:inc': 'http://www.w3.org/2004/08/xop/include' } } }, description: name, sendingName: VETS_GOV, sendingSource: sending_source } end end |
#sending_source ⇒ String
Returns sending source; currently hard coded.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/preneeds/attachment.rb', line 17 class Attachment < Preneeds::Base # string to populate #sending_source # VETS_GOV = 'vets.gov' attribute :attachment_type, Preneeds::AttachmentType attribute :sending_source, String, default: VETS_GOV attribute :file, (Rails.env.production? ? CarrierWave::Storage::AWSFile : CarrierWave::SanitizedFile) attribute :name, String attr_reader :data_handler # Creates a new instance of {Preneeds::Attachment} # # @param args [Hash] hash with keys that correspond to attributes # def initialize(*args) super @data_handler = SecureRandom.hex end # (see Preneeds::BurialForm#as_eoas) # def as_eoas { attachmentType: { attachmentTypeId: . }, dataHandler: { 'inc:Include': '', attributes!: { 'inc:Include': { href: "cid:#{@data_handler}", 'xmlns:inc': 'http://www.w3.org/2004/08/xop/include' } } }, description: name, sendingName: VETS_GOV, sendingSource: sending_source } end end |
Instance Method Details
#as_eoas ⇒ Hash
Converts object attributes to a hash to be used when constructing a SOAP request body. Hash attributes must correspond to XSD ordering or API call will fail
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/preneeds/attachment.rb', line 40 def as_eoas { attachmentType: { attachmentTypeId: . }, dataHandler: { 'inc:Include': '', attributes!: { 'inc:Include': { href: "cid:#{@data_handler}", 'xmlns:inc': 'http://www.w3.org/2004/08/xop/include' } } }, description: name, sendingName: VETS_GOV, sendingSource: sending_source } end |