Class: InvoiceBar::Address

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Searchable
Defined in:
app/models/invoice_bar/address.rb

Constant Summary

ADDRESS_COMPONENTS =
%w( street street_number city city_part postcode
extra_address_line )

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.searchable_fieldsObject



22
23
24
# File 'app/models/invoice_bar/address.rb', line 22

def self.searchable_fields
  ADDRESS_COMPONENTS
end

Instance Method Details

#copy(addressable_type: nil) ⇒ Object

Copies the address and returns a new instance.



33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/invoice_bar/address.rb', line 33

def copy(addressable_type: nil)
  InvoiceBar::Address.new(
    street: street,
    street_number: street_number,
    city: city,
    city_part: city_part,
    postcode: postcode,
    extra_address_line: extra_address_line,
    addressable_type: addressable_type
  )
end

#empty?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'app/models/invoice_bar/address.rb', line 26

def empty?
  ADDRESS_COMPONENTS.each do |attribute|
    return false unless eval "self.#{attribute}.blank?"
  end || true
end