Class: Preneeds::Address

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

Overview

Models an address from a BurialForm form

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_json

Instance Attribute Details

#cityString

Returns address city.

Returns:

  • (String)

    address city



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
# File 'app/models/preneeds/address.rb', line 19

class Address < Preneeds::Base
  attribute :street, String
  attribute :street2, String
  attribute :city, String
  attribute :country, String
  attribute :state, String
  attribute :postal_code, String

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address1: street, address2: street2, city:,
      countryCode: country, postalZip: postal_code, state: state || ''
    }

    hash.delete(:address2) if hash[:address2].blank?
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    attribute_set.map { |a| a.name.to_sym }
  end
end

#countryString

Returns address country.

Returns:

  • (String)

    address country



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
# File 'app/models/preneeds/address.rb', line 19

class Address < Preneeds::Base
  attribute :street, String
  attribute :street2, String
  attribute :city, String
  attribute :country, String
  attribute :state, String
  attribute :postal_code, String

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address1: street, address2: street2, city:,
      countryCode: country, postalZip: postal_code, state: state || ''
    }

    hash.delete(:address2) if hash[:address2].blank?
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    attribute_set.map { |a| a.name.to_sym }
  end
end

#postal_codeString

Returns address postal code.

Returns:

  • (String)

    address postal code



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
# File 'app/models/preneeds/address.rb', line 19

class Address < Preneeds::Base
  attribute :street, String
  attribute :street2, String
  attribute :city, String
  attribute :country, String
  attribute :state, String
  attribute :postal_code, String

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address1: street, address2: street2, city:,
      countryCode: country, postalZip: postal_code, state: state || ''
    }

    hash.delete(:address2) if hash[:address2].blank?
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    attribute_set.map { |a| a.name.to_sym }
  end
end

#stateString

Returns address state.

Returns:

  • (String)

    address state



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
# File 'app/models/preneeds/address.rb', line 19

class Address < Preneeds::Base
  attribute :street, String
  attribute :street2, String
  attribute :city, String
  attribute :country, String
  attribute :state, String
  attribute :postal_code, String

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address1: street, address2: street2, city:,
      countryCode: country, postalZip: postal_code, state: state || ''
    }

    hash.delete(:address2) if hash[:address2].blank?
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    attribute_set.map { |a| a.name.to_sym }
  end
end

#streetString

Returns address line 1.

Returns:

  • (String)

    address line 1



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
# File 'app/models/preneeds/address.rb', line 19

class Address < Preneeds::Base
  attribute :street, String
  attribute :street2, String
  attribute :city, String
  attribute :country, String
  attribute :state, String
  attribute :postal_code, String

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address1: street, address2: street2, city:,
      countryCode: country, postalZip: postal_code, state: state || ''
    }

    hash.delete(:address2) if hash[:address2].blank?
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    attribute_set.map { |a| a.name.to_sym }
  end
end

#street2String

Returns address line 2.

Returns:

  • (String)

    address line 2



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
# File 'app/models/preneeds/address.rb', line 19

class Address < Preneeds::Base
  attribute :street, String
  attribute :street2, String
  attribute :city, String
  attribute :country, String
  attribute :state, String
  attribute :postal_code, String

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address1: street, address2: street2, city:,
      countryCode: country, postalZip: postal_code, state: state || ''
    }

    hash.delete(:address2) if hash[:address2].blank?
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    attribute_set.map { |a| a.name.to_sym }
  end
end

Class Method Details

.permitted_paramsArray

List of permitted params for use with Strong Parameters

Returns:

  • (Array)

    array of class attributes as symbols



41
42
43
# File 'app/models/preneeds/address.rb', line 41

def self.permitted_params
  attribute_set.map { |a| a.name.to_sym }
end

Instance Method Details

#as_eoasHash

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

Returns:

  • (Hash)

    object attributes and association objects converted to EOAS service compatible hash



29
30
31
32
33
34
35
36
37
# File 'app/models/preneeds/address.rb', line 29

def as_eoas
  hash = {
    address1: street, address2: street2, city:,
    countryCode: country, postalZip: postal_code, state: state || ''
  }

  hash.delete(:address2) if hash[:address2].blank?
  hash
end