Class: MarketTown::Checkout::Address Private

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/market_town/checkout/models/address.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An Address model for validating addresses. This class is for internal use only. You should validate addresses yourself before passing them into MarketTown::Checkout.

Defined Under Namespace

Classes: InvalidError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#address_1Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def address_1
  @address_1
end

#address_2Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def address_2
  @address_2
end

#address_3Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def address_3
  @address_3
end

#companyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def company
  @company
end

#countryObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def country
  @country
end

#localityObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def locality
  @locality
end

#nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def name
  @name
end

#postal_codeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def postal_code
  @postal_code
end

#regionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def region
  @region
end

#saveObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/market_town/checkout/models/address.rb', line 39

def save
  @save
end

Class Method Details

.validate!(address_attrs) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Validates an address, throws InvalidError if invalid

Parameters:

  • address_attrs (Hash)

Options Hash (address_attrs):

  • :name (String)
  • :company (String)
  • :address_1 (String)
  • :address_2 (String)
  • :address_3 (String)
  • :locality (String)
  • :region (String)
  • :postal_code (String)
  • :country (String)

    must be valid ISO3166 alpha 2

Raises:



28
29
30
31
32
33
34
35
# File 'lib/market_town/checkout/models/address.rb', line 28

def self.validate!(address_attrs)
  address = new(address_attrs)

  if address.invalid?
    raise InvalidError.new(address: address_attrs,
                           errors: address.errors.messages)
  end
end